0
C++完全リファレンスには、「=演算子を除いて、演算子関数は派生クラスに継承されています。オーバーロードされた代入演算子の継承
しかし、私は次のコードの動作を理解cannt:
#include<iostream>
using namespace std;
int main(){
class b{
int i;
public:
int operator=(b parm){
cout<<"base overload";
};
};
class d: public b{
int j;
public:
};
b inst1,inst11;
d inst2,inst22;
int a;
inst1=inst11; //works because assignment operator is overloaded for b
inst2=inst22; //If =operator function is not inherited then why does it output "base oberload"
inst1=inst2; //works because assignment overloaded for b
// inst2=inst11; //But if b was inherited then this should also work but it doesnt
}
私は2つの出力文「ベースのオーバーロード」を期待していますが、それは3なぜを出力しています?これはナットを運転しています