Sunday, February 13, 2005

[segway] forward declaration

from http://www-subatech.in2p3.fr/~photons/
subatech/soft/carnac/CPP-INC-1.shtml

1. B only uses references or pointers to A. Use forward declaration then : you don't need to include . This will in turn speed a little bit the compilation.
  class A ;

class B {
private:
A* fPtrA ;
public:
void mymethod(const& A) const ;
} ;

2. B derives from A or B explicitely (or implicitely) uses objects of class A. You then need to include
  #include 

class B : public A {

} ;

class C {
private:
A fA ;
public:
void mymethod(A par) ;
}