54 - Derived Class Constructors
2018-01-05 本文已影响0人
社交帐号直接注册
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;
}