Hello
In my code there are 3 classes, in 2 of them i have STL lists from the type of the other class
Explanation: Class 1 has STL list from type class 2 and Class 2 has STL list from type Class 3.
And i get an error: error C2065: 'Brand' : undeclared identifier c:\users\hebrew\documents\visual studio 2010\projects\test\test\system.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include<iostream>
#include<string>
#include"Product.h"
#include"Brand.h"
#include<algorithm>
#include<list>
usingnamespace std;
class System {
private:
string personName;
string proNum;
string dayNumber;
list<Brand> Brands;
you cannot include System.h in Product.h and then Product.h in System.h
You can, because the header guards will prevent infinitely recursive header file inclusion.
Having said that, I don't understand why Product.h includes System.h, because I can't see anywhere in the posted code where the contents of Product.h depend on the contents of System.h.
Of course, this would be easier if the OP would use code tags to make the code more readable.
EDIT: I would also strongly advise against having usingnamespace std; in a header file.
Which also means that one will see the other as undefined.
Yes, and it's usually an indication that there's a problem with the design of your code.
As I said, though, in the OP's case, I think it's just a mistake. There's nothing in Product.h that uses anything in System.h, so there's no actual cyclic dependency that I can see.