zoukankan      html  css  js  c++  java
  • 对象成员数组

    #include "stdafx.h"

    #include<iostream>

    #include<memory>

    #include<string>

    using namespace std;

    class CSelsctLesson

    {

    public:

                    CSelsctLesson();

                    CSelsctLesson( string lesson ) { LessonName = lesson; }

    void setLesson(string lesname);

    string Getlesson() { return LessonName; }

    private:

    string LessonName;

    };

    CSelsctLesson::CSelsctLesson()

    {

                    LessonName = "" ;

    }

    void CSelsctLesson ::setLesson(string lesname)

    {

                    LessonName = lesname ;

    }

    class Student

    {

    int StudentID;

    string name;

    CSelsctLesson SelectLessonName[5];

    int selectNumber;

    public:

                    Student( int value , string str)

                    {

                                    selectNumber = 0;

                                    name = str ;

                                    StudentID = value;

                    }

    void Addlesson(string lesson);

    string GetLesson(int index)

                    {

    return SelectLessonName[index ].Getlesson();

                    }

    string GetStudentName() { return name; }

    int GetSelectNum()

                    {

    return selectNumber;

                    }

    };

    void Student ::Addlesson(string lesson)

    {

    if (selectNumber < 4)

                                    SelectLessonName[selectNumber++].setLesson( lesson);

    }

    int main()

    {

    Student student1(1511435, "helloworld" );

                    student1.Addlesson( "Computer");

                    student1.Addlesson( "English");

    int number = student1.GetSelectNum();

                    cout << student1.GetStudentName() << "course is:";

    for (int i = 0; i < number; i++)

                                    cout << student1.GetLesson(i) << " " ;

                    cout << endl;

                    system( "pause");

    return 0;

    }

    图像 2

  • 相关阅读:
    国内使用kubeadm部署kubernetes的完整流程
    Paxos协议笔记
    【LLVM笔记】0x00 初识LLVM 链接类型
    TLS 1.0协议
    风险指针(Hazard Pointer) 内存空间共享模型
    LRU算法
    从.git文件夹探析git实现原理
    Python爬虫与一汽项目【三】爬取中国五矿集团采购平台
    Python爬虫与一汽项目【二】爬取中国东方电气集中采购平台
    Python爬虫与一汽项目【一】爬取中海油,邮政,国家电网问题总结
  • 原文地址:https://www.cnblogs.com/summercloud/p/5544543.html
Copyright © 2011-2022 走看看