Op 04-May-15 14:59, Joseph Hesse schreef:
You need a forward declaration of City so the compiler knows that "City"
is a class:
class City;
class Person
{
private:
City *city; // the city in which the person lives
// ...
public:
// ...
};
class City
{
private:
std::set<Person> citizens;
// ...
public:
// ...
};
Note that a forward declaration suffices for the Person class because
the city member is a pointer. If the city member was an instance of the
class City it wouldn't compile because at that point the compiler
doesn't know yet how big instances of the City class will be and
therefore cannot know how big instances of the Person class would be.