L
Luca
Suppose I have a base class that contains a private member that is a
pointer to an object whose type is a derived class:
**************************************************
// file base.h
#include "derived.h"
class Base {
Derived* derived;
public:
Base(Derived* derived);
. . .
};
**************************************************
**************************************************
// file derived.h
#include "derived.h"
class Derived : public Base {
. . .
};
**************************************************
this doesn't work; to have the things work properly I have to change
the file base.h like the following:
**************************************************
// file base.h
class Derived; <------------------- here is the change!
(instead of #include
"derived.h"
class Base {
Derived* derived;
public:
Base(Derived* derived);
. . .
};
**************************************************
Do you know why?
pointer to an object whose type is a derived class:
**************************************************
// file base.h
#include "derived.h"
class Base {
Derived* derived;
public:
Base(Derived* derived);
. . .
};
**************************************************
**************************************************
// file derived.h
#include "derived.h"
class Derived : public Base {
. . .
};
**************************************************
this doesn't work; to have the things work properly I have to change
the file base.h like the following:
**************************************************
// file base.h
class Derived; <------------------- here is the change!
(instead of #include
"derived.h"
class Base {
Derived* derived;
public:
Base(Derived* derived);
. . .
};
**************************************************
Do you know why?