所以我这里有这个简单的C ++代码,没有任何下划线红色,但是当我编译它时,控制台在第10行显示4个错误,在第20行显示4个错误,在第21行显示3个错误。
//Comment
#include <iostream>
#include <vector>
#include <string>
#include "stdafx.h"
using namespace std;
string comb(vector<int> table) { //Line 10
string ret = "";
for (int i = 0; i < table.size(); i++) {
ret = ret + to_string(table[i]);
}
return ret;
}
int main()
{
vector<int> tab = { 3,4,5,6,7,99 };
cout << comb(tab);
}
答案 0 :(得分:0)
只需注释掉#include "stdafx.h"
,您的代码就可以了。
示例:
//Comment
#include <iostream>
#include <vector>
#include <string>
//#include "stdafx.h"
using namespace std;
string comb(vector<int> table) {
string ret = "";
for (int i = 0; i < table.size(); i++) {
ret = ret + to_string(table[i]);
}
return ret;
}
int main()
{
vector<int> tab = { 3,4,5,6,7,99 };
cout << comb(tab);
}
答案 1 :(得分:-1)
我现在明白了,我把#include“stdafx.h”放在#include下面。