为什么cout输出不了string字符串
#include "stdafx.h"#include "iostream"
#include "iomanip"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string stringA = "Hello word"; //定义string类型的字符串
cout << stringA << endl;
string stringB(stringA);//用另一个字符串初始化字符串
cout << "stringB= " << stringB << endl;
string strCopy1, strCopy2;
strCopy1 = stringA;//字符串之间的赋值运算
cout << "strCopy1= " << strCopy1 << endl;
strCopy2.assign(strCopy1);//将字符串赋值给本对象,相当于=操作
strCopy2.append("programing");
cout << "strCopy2= " << strCopy2 << endl;
strCopy2.insert(6, "hello");
cout << "strCopy2= " << strCopy2 << endl;
string strADD = "in c++. ";
stringB = stringA + strADD;
cout << "stringB = " << stringB << endl;
int nLocation = stringA.find_first_of("WXYZ");
cout << "The first position of w in stringA is " << nLocation << endl;
int nCom = (stringB);
cout << "compare of stringA and stringB is " << nCom << endl;
}
问题是cout<<string<<endl;//string前面的<<一直报错提示
1> d:\app\visualstudio2013\vc\include\ostream(699): 或 “std::basic_ostream<char,std::char_traits<char>> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,const char *)”