c++ - 错误 : too many arguements to function

标签 c++

我正在用 C++ 编写,但是我得到了关于

的错误

declaration of 'triangle' as multidimensional array must have bounds for all dimensions except the first

我有一个类似于下面的函数:

int func( int height, int row, int check, int triangle[][]) {
    // some code
}

我下面有一段代码是这样的:

int main(){
    int small, big;

    if( func( height, x, 0, triangle)>big){
         small = big;
         big = func( height, x, 0, triangle);
     }
}

谁能告诉我我做错了什么?

最佳答案

你可以这样使用...

template <typename TwoD>
int func(int height,int row, int check, TwoD& triangle){
}

TwoD 适用于所有二维数组类型的数据结构,示例

vector<vector<T>> 

或用户定义的类型以最大化代码重用。

关于c++ - 错误 : too many arguements to function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33195741/

相关文章:

c++ - 如何阅读 MSDN 并申请?

c++ - SFML 绘图对象在另一个对象之上

c++ - 如何检测 C 代码(需要 'extern C' )是否在 C++ 中编译

c++ - Intel CPU 的宏测试 AVX-2 架构是什么?

c++ - 如何修复 "array rvalue"无法使用 gcc-4.8 和 clang-3.7 进行编译的问题?

不提供模板参数的 C++ 类指针

c++ - 效率。函数返回值与输出参数

c++ - 纯虚函数中的默认值参数

c++ - 使用自定义帧缓冲区时深度测试不起作用

c++ - const map & 作为函数参数