What do I need to do to create two classes, which uses each other.
For example:
But, when I compile, this happens: "Error: ISO C ++ does not have any type of 'map' With no declaration forbidden " I modified my classes, Probably, this is a basic question, but I do not know the keyword to search on Google ... Code: Cell.h: Map.h: if a Even if this works, there will be no way to prepare any examples. There may be indications (or references) to each other. class A has the type of object type
class B , and
square b type of objects in
class A
class map {public: cell * cell; }
class in
class A Is b and
square b is also a
square a , then you can not do that.
class B; // Only the next announcement compiler of the name does not know // How much space a B still needs Class A {Private: BB; // failed because we do not know what B is yet. }; Class B {Private: AA; };
b b; // allocates the space for a B1, which requires the allocation of A for its A, which requires the allocation of its B, which is allocated for its A // and the space on it. It needs to be ...
class B; // Next Declaration tells the compiler to expect B type. Class A {Private: B * B; // Allocates space for only one indicator which is always known / regardless of type. }; Class B {Private: A * A; };
No comments:
Post a Comment