effective c++ 27
667 ワード
#include <iostream>
using namespace std;
class Window
{
public:
Window(){
cout<<"construct window "<<endl;
}
Window(const Window & win){
cout<<"copy construct window "<<endl;
}
virtual void on()
{
cerr <<"window "<< this << endl;
}
};
struct SWindow: public Window
{
public:
virtual void on()
{
(static_cast<Window>(*this)).on();// Window
cerr <<" swindow " << this << endl;
}
};
int main()
{
SWindow w;
w.on();
Window win1 = w;// Window
Window win(w);
return 0;
}