|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<iostream>
using namespace std;
class CCourse
{
string name;
int creditHour;
public:
void setname(string x)
{name = x;}
string getname()
{return name;}
void setcreditHour(int x)
{creditHour = x;}
int getcreditHour()
{return creditHour;}
};
class CStudent
{
public:
CStudent(int courseNumber,string name,int birthmonth,int birthday)
{
this->courseNumber = courseNumber<=10?courseNumber:10;
this->name = name;
this->birthday = birthday;
this->birthmonth = birthmonth;
}
void set(int x,string coursename,int credit) 《-----------------------------------这里出的问题
{
courseList[x]->setname(coursename);
courseList[x]->setcreditHour(credit);
}
private:
CCourse* courseList[10];
int courseNumber;
string name;
int birthmonth;
int birthday;
};
int main()
{
CStudent p(4, "张三", 1, 1);
p.set(0, "高数", 4); 《--------------------------------------这里出的问题
p.set(1, "c++", 4);
p.set(2, "线性代数", 3);
p.set(3, "大学英语", 3);
} |
|