#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
class A{
public:
A():m_year(0){}
A(int n){m_year = n;}
public:
int m_year ;
};
class B : public A
{
public:
B(){}
B(int n):A(n){}
~B(){}
};
int main()
{
B cb(20);
B cb2;
cout<< "cb year is:" << cb.m_year << " cb2 year is:"<<cb2.m_year <<endl;
return 0;
}
运行结果如下:
cb year is:20 cb2 year is:0