首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

求大伙指教啊error C2679: binary '<<' : no operator defined which 。

2012-10-26 
求大家指教啊error C2679: binary : no operator defined which 。。。#include iostreamusing namesp

求大家指教啊error C2679: binary '<<' : no operator defined which 。。。
#include <iostream>
using namespace std;
struct Person{
string name;
bool gender;
int age;
Person* lover;
Person(string n,bool g){
lover=NULL;
age=0;
}
void show()
{
cout<<"大家好,我是超级"<<(gender?"帅哥":"美女")<<name<<"今年"<<age<<",";

if(lover==NULL)
cout<<"未婚";
else
cout<<"我的爱人是"<<lover->name;
cout<<",很高兴认识大家!"<<endl;
}
};
int main()
{
Person a("大大",false),b("开开",true);

a.show();
b.show();
system("pause");
return 0;
}

程序如上 
  错误信息为
  --------------------Configuration: 0412amb - Win32 Debug--------------------
Compiling...
0412amb.cpp
D:\test\0412amb.cpp(14) : 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)
D:\test\0412amb.cpp(19) : 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)
Error executing cl.exe.

0412amb.exe - 2 error(s), 0 warning(s)


[解决办法]
#include <string>

热点排行