#include <iostream>
using namespace std;
class Window
{
public:
Window()
{
Create();
}
virtual ~Window()
{
Destroy();
}
virtual void Create()
{
cout << "Base class Window" << endl;
}
virtual void Destroy()
{
cout << "Base class Destroy" << endl;
}
};
class CommandButton : public Window
{
public:
void Create()
{
cout << "Derived class Command Button" << endl;
}
void Destroy()
{
cout << "Derived class Destroy" << endl;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
Window *x, *y;
x = new Window();
x->Create();
y = new CommandButton();
y->Create();
delete x;
delete y;
return 0;
}
질문 1
위의 코드의 출력값을 예상해보고 왜 그런 결과가 나오는지 설명해보라.