美文网首页
54 - Derived Class Constructors

54 - Derived Class Constructors

作者: 社交帐号直接注册 | 来源:发表于2018-01-05 17:35 被阅读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;
}

相关文章

网友评论

      本文标题:54 - Derived Class Constructors

      本文链接:https://www.haomeiwen.com/subject/lausnxtx.html