标签:
#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;
}
标签:
原文地址:http://www.cnblogs.com/summercloud/p/5544543.html