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

a2175919 2012-07-05 10:55:00
#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)
...全文
2301 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
南京搬运工 2012-10-15
  • 打赏
  • 举报
回复
我也碰到了ASSERT_VALID(this);

CDrawObj::Serialize(ar);

if (ar.IsStoring())
{
ar << m_extent;
ar << m_pClientItem;
}
else
a2175919 2012-07-05
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
#include <string>
[/Quote]
嗯 谢谢啊 可以了
taodm 2012-07-05
  • 打赏
  • 举报
回复
#include <string>

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧