Because the implicitly declared copy assignment operator of B
hides the implicitly declared copy assignment operator of A
.
So for the line b = a
, only the the operator=
of B
is a candidate. But its parameter has type B const&
, which cannot be initialized by an A
argument (you would need a downcast). So you get an error.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…