0
私はBaseクラスと生成されたコードを再利用するためにプライベート継承を使用するSomethingという名前の "子"クラスを持っています。C++のプライベート継承と、再利用するが基本クラスの演算子を飾る方法は?
class Base {
protected:
Base();
public:
virtual ~Base(){}
void cool();
Base& operator=(const Base& other);
};
class Something : private Base {
public:
Something();
void cool(){
// own stuff
// call method from base
Base::cool();
// own stuff
}
Something& operator=(const Something& other){
if (this != &other){
// do own things
ここでは装飾の間に、演算子の呼び出し=基本クラスからする必要があります。 しかし、私は正しい方法でこれをどうやってやるべきかわかりません。
(dynamic_cast<Base>(*this)).operator =(dynamic_cast<Base>(other));
// do own things
}
return *this;
}
}
敬具:私はこのような dynamic_castのものを使用する必要があります。
ない 'this->ベース::演算子は=(その他)'働くだろうか? – melpomene
'Base :: operator =(other)' – Arunmu