#include “stdafx.h”
#include <iostream>
using namespace std;
class Studentid
{
int id;
public:
Studentid()
{
id = ++id;
}
};
class Student
{
string name;
Studentid sid;
public:
Student(string n = “noname”)
{
cout << “Construing student ” + n + “\n”;
name = n;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
#include <iostream>
using namespace std;
class Studentid
{
int id;
public:
Studentid()
{
id = ++id;
}
};
class Student
{
string name;
Studentid sid;
public:
Student(string n = “noname”)
{
cout << “Construing student ” + n + “\n”;
name = n;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
解决方案
14
加上头文件#include<string>就行了
7
标准库没有重载+(string s) 这种类型吧,<<(string s) 也没有
6
你没包含#include <string>头文件
string类型运算符的重载在<string>头文件中
string类型运算符的重载在<string>头文件中