[英]VC++ error C2146: syntax error : missing ')' before identifier 'pFirst'
我是C ++的新手,但是我在C#和Java方面做得很好。 我正在这里做一些基本的练习:
// HelloWorld.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
bool isSame(int[] pFirst, int[] pSecond, int pLength) {
}
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
那是我的整个文件,但是VC ++(我正在使用VS 2013)不断抱怨:
1 IntelliSense: expected a ')'
在isSame
声明行。
我做错了什么? 我正在编写一个函数来比较两个数组是否包含相同的值,这是解决方案:
bool ArrayEq( int A1[], int A2[], int size ) {
for (int k=0; k<size; k++) {
if (A1[k] != A2[k]) return false;
}
return true;
}
正确的语法是int pFirst[]
。
但是首先,此函数已存在于标准库中 ,第二个std::vector
重载了operator ==
。
两者都比手工编写的代码更受青睐,并且std::vector
比C样式的数组更好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.