标签:include printf func argv nbsp sub() 动态 base argc
#include <stdio.h>
struct Base
{
int x;
Base()
{
x = 100;
}
void func1()
{
printf("Base func1()\n");
}
virtual void func2()
{
printf("Base virtual func2()\n");
}
};
struct Sub:Base
{
int x;
Sub()
{
x = 200;
}
void func1()
{
printf("Sub func1()\n");
}
virtual void func2()
{
printf("Sub virtual func2()\n");
}
};
void test(Base *pb)
{
printf("x: %d\n", pb->x);
pb->func1();
pb->func2();
}
int main(int argc, char **argv)
{
Base base;
test(&base);
Sub sub;
test(&sub);
}
标签:include printf func argv nbsp sub() 动态 base argc
原文地址:http://www.cnblogs.com/roadmap99/p/6757981.html