B
Ben Taylor
I've asked about includes before in this group in order to
stop files being #included either twice or not at all, and
somebody said to use extern keyword for global variables
that need to be used in another cpp file, and to also put
all the includes of header files in the stdafx.h file, and
then to have every cpp file just include stdafx and
nothing else.
I've done this, so far with success.
However now I want to create a class A, that manages a
load of objects of type class B on the heap (using a
CTypedPtrList<CObList, ClassB*>, performing various
operations on them and then calling delete on them in its
constructor. However I want to have a variable in the
manager class that the objects can all reference,
consequently all the objects have to have a reference to
the manager class, which means they need to know its
definition. Thus, class A has to be able to 'see' class B,
and class B has to be able to 'see' class A, when
compiling. How do I arrange the include statements so that
it doesn't get either 'redefinition' or 'must have
class/struct/union type'?
stop files being #included either twice or not at all, and
somebody said to use extern keyword for global variables
that need to be used in another cpp file, and to also put
all the includes of header files in the stdafx.h file, and
then to have every cpp file just include stdafx and
nothing else.
I've done this, so far with success.
However now I want to create a class A, that manages a
load of objects of type class B on the heap (using a
CTypedPtrList<CObList, ClassB*>, performing various
operations on them and then calling delete on them in its
constructor. However I want to have a variable in the
manager class that the objects can all reference,
consequently all the objects have to have a reference to
the manager class, which means they need to know its
definition. Thus, class A has to be able to 'see' class B,
and class B has to be able to 'see' class A, when
compiling. How do I arrange the include statements so that
it doesn't get either 'redefinition' or 'must have
class/struct/union type'?