c++ 輸出string的問題 cout

原文: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;

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章