いくつかの導電転送問題をシミュレートするコードをプログラミングしていますが、メッシュの生成に悩まされています。C++で動作しない外部変数宣言(ヘッダーファイルでクラッシュする)
#include <iostream>
#include <fstream>
#include <string>
#include "library.h"
using namespace std;
int main (void){
// Number of divisions
int xdivA, xdivB, ydivA, ydivB, ydivAB;
xdivA=30; xdivB=30; ydivA=30; ydivB=30; ydivAB=30;
int N=xdivA+xdivB;
int M=ydivA+ydivB+ydivAB;
struct controlvolume celln[N][M];
}
ヘッダファイル:
//GLOBAL VARIABLES
extern int N;
extern int M;
//STRUCTURE TYPES
struct prop {
double rho, Cp, k;
};
struct points {
double x, y;
};
struct controlvolume {
points coord;
prop localmaterial;
};
// FUNCTIONS
double Mesh(controlvolume celln[N][M], int xdivA, int xdivB, int ydivA, int ydivB, int ydivAB, points initialp[4], prop materials [4]);
Mesh.cpp
#include <iostream>
#include "library.h"
using namespace std;
double Mesh(controlvolume celln[N][M], int xdivA, int xdivB, int ydivA, int ydivB, int ydivAB, points initialp[4], prop materials[4]){
celln[2][2].coord.x=initialp[3].x;
celln[2][2].localmaterial.rho=materials[2].rho;
}
使用されるすべての変数私が間違っている変数の宣言を使用することができるので、これは... MAINありますmainpの中でinitialp、materialsなどの宣言が宣言されています。私はスペースを節約するためにここにそれらを含めなかった。
私は取得していますエラーは次のとおりです。
[エラー]バインドされた配列は前に整数定数ではありません「]」トークン
[エラー]配列のバインドが前に整定数ではありません「]」トークン'' トークン
[エラー] Lであるように見える非修飾-ID
'INT' の前に予想される前
[エラー]予想 ')'関数Meshが定義されている場合、ibrary.hファイル...
私はあなたの助けに感謝します! :)