#include <iostream>
using namespace std;
class Base{
int a;
public:
virtual void func1(){
cout << "func1" << endl;
}
virtual void func2(){
cout << "func2" << endl;
}
};
class Derived : public Base{
int b;
public:
virtual void func1(){
cout << "D::func1" << endl;
}
virtual void func3(){
cout << "func3" << endl;
}
};
class Derived2 : public Derived{
int c;
public:
virtual void func1(){
cout << "D2::func1" << endl;
}
virtual void func3(){
cout << "D2::func3" << endl;
}
virtual void func4(){
cout << "func4" << endl;
}
};
int main()
{
Base a;
a.func1();
Derived b;
b.func3();
Derived2 c;
c.func3();
return 0;
}
가상함수 테이블 샘플
Base 클래스의 가상함수 테이블만 보인다.