C++相談室 part50
■ このスレッドは過去ログ倉庫に格納されています
0259デフォルトの名無しさん
2006/06/15(木) 04:50:05class base {
virtual base* this_p(void) = 0;
};
class derived : public base {
derived* this_p(void) { cout << "derived called" << endl; return this; }
};
class derived2 : public derived {
int value;
derived2* this_p(void) { cout << "derived2 called" << endl; return this; }
};
で、
base* p = new derived2;
p->this_p(); // これは"derived2 called"を出力
p->this_p()->value; // これはエラー
となる理由を教えてください・・・。
■ このスレッドは過去ログ倉庫に格納されています