这里的语法有什么问题?我对此有多个问题,在c ++

问题描述 投票:-1回答:1

我对C ++还是很陌生,所以请原谅我的无能。这是代码,它是关于尝试找到2个矩阵的和:

#include <iostream>
#include "functions.h"
using namespace std;

void saisir_matrice(int l, int c, int matriceA[][colonnes], int matriceB[][colonnes])
{
    cout << "Entrez vos numéros" << endl;
    for (int i = 0; i < l; i++)
    {
        for (int j = 0; j < c; j++)
        {
            cin >> matriceA[i][j];
        }
    }
}

我不确定是什么问题,但是第一行出现了一些错误,例如:

  • int之前的预期合格ID

  • 符号冒号无法解析

  • 期望')'在','令牌之前>]

  • 我知道这些错误的含义,这意味着我编写函数的方式存在问题,但是我似乎在第一行中找不到它们。

<< [edit

到目前为止,这里的function.h看起来是这样: #ifndef FUNCTIONS_H_ #define FUNCTIONS_H_ void saisir_matrice(int lignes, int colonnes, int matriceA[][colonnes], int matriceB[][colonnes]); #endif /* FUNCTIONS_H_ */
这是我的主要功能:

#include <iostream> #include "functions.h" using namespace std; int main() { int COLONNES; int LIGNES; cout << "entrez 2 nombres" << endl; cin >> COLONNES; cin >> LIGNES; int matriceA[LIGNES][COLONNES]; int matriceB[LIGNES][COLONNES]; saisir_matrice(LIGNES, COLONNES, matriceA, matriceB); return 0; }

重点是尝试将数组作为变量传递,但是我找不到很多语法错误。这是错误消息:

- Symbol 'colonnes' could not be resolved - Symbol 'colonnes' could not be resolved - expected ‘)’ before ‘,’ token - expected unqualified-id before ‘int’

我对C ++还是很陌生,所以请原谅我的无能。这是代码,它是关于尝试找到2个矩阵的和:#include 

#include“ spaces.h” using namespace std;无效...

c++ function multidimensional-array syntax
1个回答
0
投票
一种方法可以是
© www.soinside.com 2019 - 2024. All rights reserved.