Всем привет. Нужно написать класс хранение и класс заполнения так что бы класс заполнения заполнял постепенно класс хранения, т.е. записывал по одному элементу. Создал примерный код, но что-то тут с подключением творится. Никак разобраться не могу , может кто, что подскажет
файл main.cpp:
| Код |
#include "stdafx.h" #include "A.h"
#include <iostream> using namespace std;
int main() { A a; a.fill();
for( unsigned int i=0; i<a.vec.size(); i++) { cout << a.vec[i] << endl; } return 0; }
|
Файл A.h:
| Код | #ifndef A_H #define A_H
#include "B.h" #include <vector> using namespace std;
class A { public: A(){} void Add(int el) { vec.push_back(el); } void fill() { b.fill(this); }
vector<int> vec; private: B b; };
#endif
|
файл B.h:
| Код | #ifndef B_H #define B_H
#include <vector> #include "A.h" using namespace std;
class B { public: B(){}
void fill(A* pointer) { for(int i=0; i<10; i++) pointer->Add(i); } };
#endif
|
Выдает такую ошибку:
| Код | Error 1 error C2061: syntax error : identifier 'A' d:\programming\opit_include\opit_include\b.h 13 Error 2 error C2065: 'pointer' : undeclared identifier d:\programming\opit_include\opit_include\b.h 16 Error 3 error C2227: left of '->Add' must point to class/struct/union/generic type d:\programming\opit_include\opit_include\b.h 16 Error 4 error C2660: 'B::fill' : function does not take 1 arguments d:\programming\opit_include\opit_include\a.h 19
|
|