1.main.cpp
#include <iostream>
#include "Mother.h"
#include "Gaughter.h"
using namespace std;
int main()
{
Mother ma;
Gaughter dina;
}
2.Mother.h
#ifndef MOTHER_H
#define MOTHER_H
class Mother
{
public:
Mother();
~Mother();
};
#endif // MOTHER_H
3.Mother.cpp
#include <iostream>
#include "Mother.h"
#include "Gaughter.h"
using namespace std;
Mother::Mother()
{
cout << "i am a mother111" << endl;
}
Mother::~Mother()
{
cout << "a mother111" << endl;
}
4.Gaughter.h
#include <iostream>
#include "Mother.h"
#include "Gaughter.h"
using namespace std;
Mother::Mother()
{
cout << "i am a mother111" << endl;
}
Mother::~Mother()
{
cout << "a mother111" << endl;
}
5.Gaughter.cpp
#include <iostream>
#include "Mother.h"
#include "Gaughter.h"
using namespace std;
Gaughter::Gaughter()
{
cout << "i am a mother222" << endl;
}
Gaughter::~Gaughter()
{
cout << "a mother222" << endl;
}
54 - Derived Class Constructors and Destructors
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- There are some differences between a Chinese class and an...
- 在使用gradle加载jdbc驱动的时候,如果gradle版本过低 会出现以下错误信息,只要升级下gradle版本即可
- Note that the "use" operator for traits (inside a class) ...