#include <iostream>
using namespace std;
int main()
{
string strTest="hello";
//這樣會報錯
cout << "OutPut : " << strTest <<endl;
//這樣輸出正常
cout << "OutPut : " << strTest.c_str() <<endl;
return 0;
}
如果要正常使用cout輸出string,則要添加 #include<string>
解析如下:(待續)