Some code first:
class CInner {
public:
CInner( const CInner& another ) { //impl here }
private:
// some member variables
}
class COuter {
public:
COuter( const CInner& inner ) : inner( inner ) {}
private:
CInner inner;
}
Yes, in COuter::COuter( const CInner& )
the parameter has the same name as the member variable.
In VC++ that works - VC++ gets the idea that it is only reasonable to initialize the member variable with the parameter and that's what happens - CInner::inner
gets initialized with the parameter. But when the same is compiled with GCC it is interpreted in another way: GCC initializes CInner::inner
with itself and so it is left uninitialized.
Which of the compilers is right?