c++ 输出string的问题 cout << string

来源:互联网 发布:日俄战争全史淘宝 编辑:程序博客网 时间:2024/06/01 21:41

原文:http://blog.csdn.net/id19870510/article/details/5316290

 us.name = "123";

   
  cout << us.name << endl;

 

 

=====================================

 

程序运行时报一个异常

 

C2679: binary '<<' : no operator defined which takes a right-hand operand of type 

 

 

错误原因:#include<iostream.h>中string类没有重载"<<"操作符. 

 

 

cout << us.name.c_str() << endl;

 


0 0
原创粉丝点击