如下cpp文件名称为(继承中的对象模型) 在下边命令中会用到名称
#include <iostream>
using namespace std;
class Base
{
public:
int m_A;
protected:
int m_B;
private:
int m_C;
};
class son :public Base
{
public :
int m_D;
};
void test01()
{
cout << "size of son= " << sizeof(son) << endl;
}
int main()
{
test01();
cout << "\n " << endl;
system("pause");
return 0;
}
利用开发人员命令提示工具查看
继承中的构造析构函数
#include <iostream>
using namespace std;
class Base
{
public :
Base()
{
cout << "Base的构造函数" << endl;
}
~Base()
{
cout << "Base的析构函数" << endl;
}
};
class son : public Base
{
public:
son()
{
cout << "son的构造函数" << endl;
}
~son()
{
cout << "son的析构函数" << endl;
}
};
void test01()
{
son s;
}
int main()
{
test01();
cout << "\n " << endl;
system("pause");
return 0;
}