This is a followup of this question
in the following code, why does line 1 compiles while line 2 and 3 does not (using visual C++ 2010)
class ABase
{
protected:
ABase() {}
~ABase() {}
private:
ABase( const ABase& );
const ABase& operator=( const ABase& );
};
class A : ABase
{
};
class B
{
public:
B() {}
~B() {}
private:
B( const B& );
const B& operator=( const B& );
};
int main( void )
{
A a = A(); // line 1
A a2( a ); // line 2
B b = B(); // line 3
return 0;
}
(note BA is a copy of boost::noncopyable)
edit:
My problem is not to know why line 2 and 3 does not compile (I know that, the copy constructor is private), but why line 1 does.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…