Start New Discussion within our Software Development Community

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)


using namespace std;

class StudentID{

    int value;


     static int nextStudentID = 0;
	 value = ++nextStudentID;
	 cout << "Assigning student id "<<value<<endl;



class Student{

    string name;
	StudentID id;

	Student(string n = "noName"){
     cout << "Constructing student " <<n<<endl; //error C2679
	 name = n;



void main(){
	Student s("Randy");

This article has been dead for over six months. Start a new discussion instead.