프로그래밍 퀴즈 – 상속

  • Post author:
  • Post category:칼럼
  • Post comments:0 Comments
  • Post last modified:January 25, 2016
#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

위의 코드의 출력값을 예상해보고 왜 그런 결과가 나오는지 설명해보라.

Author Details
Kubernetes, DevSecOps, AWS, 클라우드 보안, 클라우드 비용관리, SaaS 의 활용과 내재화 등 소프트웨어 개발 전반에 도움이 필요하다면 도움을 요청하세요. 지인이라면 가볍게 도와드리겠습니다. 전문적인 도움이 필요하다면 저의 현업에 방해가 되지 않는 선에서 협의가능합니다.
0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments