调试错误解决方案

1、#ifdef 1

#endif

报错:

fatal error C1016: #if[n]def expected an identifier

解决方法:不能使用数字,必须是字母或者下划线

2、

error C2679: 二进制“<<”: 没有找到接受“std::string”类型的右操作数的运算符(或没有可接受的转换)

int main( ) { try { string strg1("Test"); string strg2("ing"); strg1.append(strg2, 4, 2); cout<<strg1<<endl; } catch (exception &e) { cerr<<"Caught: "<<e.what()<<endl; cerr<<"Type: "<<typeid(e).name()<<endl; 
解决方法:
少了 #include <string> 头文件,加上就对了。
原文地址:https://www.cnblogs.com/dingxiaoqiang/p/6773062.html