hi:
I have a trouble on the codes below, if I were to insert string n into the following string "Constructing student" ,the compile would appear error C2679. I don't know where any error the code have.
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)
#include<iostream>
using namespace std;
class StudentID{
int value;
public:
StudentID(){
static int nextStudentID = 0;
value = ++nextStudentID;
cout << "Assigning student id "<<value<<endl;
}
};
class Student{
string name;
StudentID id;
public:
Student(string n = "noName"){
cout << "Constructing student " <<n<<endl; //error C2679
name = n;
}
};
void main(){
Student s("Randy");
}