Skip to content

Conversation

@westwood0722
Copy link
Contributor

#include <iostream>
using namespace std;

class Base // 추상 클래스
{
public:
    virtual void show() = 0; // 순수가상함수
};

class Derived1 : public Base
{
public:
    void show() { cout << "Derived1" << endl; };
};

class Derived2 : public Base
{
public:
    void show() { cout << "Derived2" << endl; };
};

int main(int argc, char const* argv[])
{
    //Base bs; 추상클래스의 객체 생성 불가능
    Derived1 dr1;
    Derived2 dr2;

    dr1.show();
    dr2.show();

    return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant