#include<iostream>
using namespace std;
class A{
public:
void normal_func(int x)
{
cout<<"base_class normal func int x"<<endl;
}
virtual void virtual_func(int x)
{
cout<<"base_class virtual_func int x"<<endl;
}
};
class B : public A
{
public:
void normal_func(int x)
{
cout<<"derived_class normal func int x"<<endl;
}
virtual void virtual_func(int x)
{
cout<<"derived_class virtual_func int x"<<endl;
}
};
int main(int argc, char *argv[])
{
A a , *p;
p=&a;
int i=1;
char c='d';
p->normal_func(i);
p->virtual_func(i);
B b;
p=&b;
p->normal_func(c);
p->virtual_func(c);
b.normal_func(c);
b.virtual_func(c);
return 0;
}
/*
派生类所有参数为int时:
consequence:
base_class normal func int x
base_class virtual_func int x
base_class normal func int x
derived_class virtual_func int x
derived_class normal func int x
derived_class virtual_func int x
派生类所有参数为char时:consequence:
base_class normal func int x
base_class virtual_func int x
base_class normal func int x
base_class virtual_func int x
derived_class normal func char x
derived_class virtual_func char x
*/
ABOUTYOU
慕田峪4524236