#include <iostream>
using namespace std;
/*
本例程练习:C++中的结构体
C++中,结构体与类除了类成员的默认访问控制不同其余是一样的,都支持面向对象特性。
*/
struct aa
{
aa(int i)
{
m_a = i;
}
virtual void p()
{
cout << "a:m_a = " << m_a << "/n";
}
int m_a;
};
struct bb:public aa
{
bb(int i, int j):aa(i)
{
m_b = j;
}
virtual void p()
{
cout << "b:m_b = " << m_b << "/n";
cout << "b:m_a = " << m_a << "/n";
aa::p();
}
int m_b;
};
int main(void)
{
aa* pa;
aa a(3);
bb b(1,2);
pa = &a;
pa->p();
pa = (aa*)&b;
pa->p();
cin.get();
return 0;
}