一个关于string的错误
哥哥姐姐们帮忙看下这个程序该怎么修改 谢谢了
程序代码:#ifndef COURSE_H
#define COURSE_H
#include <vector>
#include <string>
using namespace std;
class CCourse
{
public:
Course(const string &courseName);
string getCourseName();
void addStudent(const string &student);
string *getStudent();
int getNumberOfStudents();
private:
string m_scourseName;
vector<string> v_sstudent;
int m_inumberOfStudents;
};
#endif#include "CourseClass.h"
#include <iostream>
using namespace std;
CCourse::Course(const string &courseName)
{
m_inumberOfStudents = 0;
this->m_scourseName = courseName;
}
string CCourse::getCourseName()
{
return m_scourseName;
}
void CCourse::addStudent(const string &student)
{
v_sstudent.push_back(student);
m_inumberOfStudents++;
}
string *CCourse::getStudent()
{
return v_sstudent.begin();
}
int CCourse::getNumberOfStudents()
{
return m_inumberOfStudents;
}#include "CourseClass.h"
#include <iostream>
using namespace std;
void main()
{
CCourse course("Database");
string stuName;
bool flag = 1;
while(flag)
{
cout<<"请输入添加学生的姓名:"<<endl;
cin>>string stuName;
course.addStudent(stuName);
cout<<"继续加入学生? 是(1) 否(0)"<<endl;
cin>>flag;
}
cout<<"本课堂的学生为"<<course.getCourseName()<<endl;
cout<<"本课堂共有学生的人数为"<<course.getNumberOfStudents()<<endl;
cout<<"检测通过"<<endl;
}系统总是提示一些莫名其妙的错误error C2664: '__thiscall CCourse::CCourse(const class CCourse &)' : cannot convert parameter 1 from 'char [9]' to 'const class CCourse &'
Reason: cannot convert from 'char [9]' to 'const class CCourse'
error C2275:'string' : illegal use of this type as an expression
c:\program files\microsoft visual studio\vc98\include\xstring(612) : see declaration of 'string'






