Hello,
I have two cl*****, C_A and template<typename T>C_B which are derived
"private" from the base cl***** C_A_ resp. template<typename T>C_B_.
The behaviour is quite different. The users of C_B can access the
variable var of C_B_, but not the users of C_A. Moreover, in C_A the
visibility of var is also controlable via the construct "private: /
public: using C_A_::var;", but this is not the case for C_B.
Can sb. explain the different behaviour.
I'm using the g++ Version 4.1.3.
class C_A_
{
public:
int var;
virtual ~C_A_( void ){}
};
class C_A : private C_A_
{
private:
using C_A_::var;
public:
C_A( void ){}
virtual ~C_A(void) {}
};
template<typename T>
class C_B_
{
public:
T var;
virtual ~C_B_( void ){}
};
template<typename T>
class C_B : private C_B_<T>
{
private:
using C_B_<T>::var;
public:
C_B( void ){}
virtual ~C_B(void) {}
};
int main(int argc, char* argv[])
{
C_B<int> oB;
oB.var = 5;// no error from the compiler
C_A oA;
oA.var = 5;// error: »int C_A_::var« is not accessible
return 0;
}//