//类成员的初始化
//VC6中报错为
C:\vc6\MyProjects\5\5.cpp(28) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversion)
执行 cl.exe 时出错.
//求大神帮帮忙
#include<iostream>
using namespace std;
class StudentID{
int value;
public:
StudentID(int id=0){
value=id;
cout<<"Assigning student id "<<value<<endl;
}
};
class Student{
string name;
StudentID id;
public:
Student(string n="no name", int ssID=0):id(ssID),name(n){
cout<<"Constructing student "<<n<<"\n";
}
};
int main(){
Student s("Randy",58);
Student t("Jenny");
return 0;
}