一个小问题,字符串就是不“出来”?请教一下。
#include<iostream>using namespace std;
class StudentID{
int value;
public:
StudentID(){
static int nextStudentID=0;
value=++nextStudentID;
cout<<"Assigning student id "<<value<<"\n";
}
};
//
class Student{
string name;
StudentID id;
public:
Student(string n="noName"){
cout<<"Constructing student "+n+"\n"; //line 20
name=n;
}
};
//
int main()
{
Student s("Randy");
return 0;
}
正常结果应该是:
Assigning student id 1
Constructing student Randy
可是总是报错 :line 20 2个错误.实在是看不出来了。呵呵,请高手指导。