昨天下午遇上了一个字符串的问题,后来得到高睿指点明白了。
#include <string>
#include <iostream>
using namespace std;
int main()
{
string strTmp;
strTmp="MetarNet" + "lczhao";
cout<<strTmp<<endl;
return 0;
}
总是会出现 error C2110: cannot add two pointers 这个错误。
后来经过验证,明白了"MetarNet" 和 "lczhao"都是字符串常量,不能进行“+”操作,解决的办法就是要经过字符转化或者在字符串常量前出现字符串变量。
即:strTmp=sting("") + "MetarNet" + "lczhao";
或strTmp=sting(MetarNet") + "lczhao";
今天出现了不能调试的问题,后来上网一查得知是在project->settings ->c++ ->project options里面加上 /GX /Zi就好了,没有他们VC会自动作优化处理。