Define Class as an array

Hi Everyone, I am new to C++, so fare I did more than 1000 lines in Clion (resolution of algorithm, use of matrix, inverse matrix and etc..). I was very satisfied with the results.

I decided to move to Visual studio, and start coping the files but I am having a lot of problems, it seems linked to the compiler...

One of the problem is as follow:

I need to define a class as an array that the size will change with an input variable. VS compiler did not accept the size of class array as variable (should be defined as const) - SO I changed the structure and included the class definition in same input class file:

This is the class array function:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

class ZY_Cal {
public:
 double Base ....

double GetGenPU(double MVA, double V, double R, double Xl, double Xc, double MVAb, double Vb, int PrimG)
	{

		Base = MVAb / (Vb*Vb);
		Vpu = V / Vb;
		Xlpu = Xl * (V*V / MVA)*Base;
		Rpu = R * (V*V / MVA)*Base;
		//Xcpu=Xc*(V*V/MVA)*Base;
		Ib = MVAb / (sqrt(3)*Vb);
		P = PrimG;

		complex<double> Z(Rpu, Xlpu);
		Zpu = Z;

		return 0;}
 
In an other class:

class Input_Data {
public: X .....

Cont Int nGen = 5; // 5 Generators

ZY_Cal Gen [nGen];

for (int p = 0; p < nGen; p++) {
Gen[p].GetGenPU (,,,,);

X = Gen[p].Base;
....

I am getting this error: 

error C2065: 'ZY_Cal': undeclared identifier;
error C2146: syntax error: missing ';' before identifier 'Gen'
C2228: left of '.GetGenPU ' must have class/struct/union
....


Can you help explain how to create and use a class array that the size will chge according to const variable.

Thank you.
It seems to be saying that Input_Data doesn't know what XY_Cal is. Presumably you need to include XY_Cal's header before Input_Data.
Thank you tpb. I moved #include "ZY_Cal.h" from main to Input_Data and the error gone.


Topic archived. No new replies allowed.