美文网首页
53 - protected Members

53 - protected Members

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

}

相关文章

  • 53 - protected Members

  • c# 8系列(一)

    readonly struct members default interface members switch ...

  • Lesson: Members

    本系列翻译自Oracle官方教程,半翻译,半读后感性质。文末会附上原文链接。 反射定义了1个接口:Member,和...

  • 2-Gitlab-项目添加成员

    进入某个项目,点击 Settings -> Members,填写下图方框中的东西 Select members t...

  • protected

    Order类 SubOrder类(Order不同包下的子类)

  • 工厂模式案例

  • List of Eurozone Members

    List of Eurozone Members Austria Belgium Cyprus Estonia F...

  • My family members

    今天就写写我的家人好了,一个放在上亿家庭中很普通的家庭,但在我的世界中却是难得幸福的家庭,以致于熟悉我的朋友都羡慕...

  • Discovering Class Members

    本系列翻译自Oracle官方教程,半翻译,半读后感性质。文末会附上原文链接。 类有3大成员:字段(field)、方...

  • Members of subclass not initiali

    Swift 项目中千万不要给 NSObject 提供默认 init 方法,父类和子类在同一module下还没有问题...

网友评论

      本文标题:53 - protected Members

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