主题:请教
#include<iostream>
using namespace std;
class studentid{
int value;
public:
studentid(int id=0){
value=id;
cout<<"assigning student id"<<value<<"\n";
}
};
class student{
string name;
studentid id;
public:
student(string n="noname",int ssid=0){
cout<<"constructing student"<<n;
name=n;
studentid id(ssid);
}
};
int main()
{
student s("randy",58);
}
提示出错:E:\VC文件库\9.cpp(17) : 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)
请各位解答下
using namespace std;
class studentid{
int value;
public:
studentid(int id=0){
value=id;
cout<<"assigning student id"<<value<<"\n";
}
};
class student{
string name;
studentid id;
public:
student(string n="noname",int ssid=0){
cout<<"constructing student"<<n;
name=n;
studentid id(ssid);
}
};
int main()
{
student s("randy",58);
}
提示出错:E:\VC文件库\9.cpp(17) : 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)
请各位解答下