Say we have a situation like this:
base.h:
class Base { };
derived.h:
#include "base.h"
class Derived : public Base { };
extern Derived *variable;
derived.cpp:
#include "derived.h"
Derived *variable;
Is it correct to declare variable
as a pointer to Base
in elsewhere.cpp?
class Base;
extern Base *variable;
The C++Builder linker doesn't complain and everything seems to work. Is this safe and correct according to the standard, or should every declaration of variable
be of the same type?