1.main.cpp
#include <iostream>
#include "Mother.h"
#include "Gaughter.h"
using namespace std;
int main()
{
Gaughter tinaa;
tinaa.doSomething();
return 0;
}
2.Mother.h
#ifndef MOTHER_H
#define MOTHER_H
class Mother
{
public:
int publicv;
protected:
int protectedv;
private:
int privatev;
};
#endif // MOTHER_H
3.Mother.cpp
#include <iostream>
#include "Mother.h"
#include "Gaughter.h"
using namespace std;
4.Gaughter.h
#ifndef GAUGHTER_H
#define GAUGHTER_H
class Gaughter:public Mother
{
public:
void doSomething();
};
#endif // GAUGHTER_H
5.Mother.h
#include <iostream>
#include "Mother.h"
#include "Gaughter.h"
using namespace std;
void Gaughter::doSomething()
{
publicv = 1;
protectedv = 2;
}
网友评论