Hallo I am trying to declare an array in a struct and when I declare the size as a constant variable it shows me this error
a nonstatic member reference must be relative to a specific object
and if I declare the constant variable out of the struct scope the error goes away.
here is my code:
struct Student{
string name;
string birthday;
int studyYear;
string Faculty;
string Department;
const int MaxNrOfCrs = 10; // here is my error
const int Grade = 1; // The same error appears here also
Course crs[MaxNrOfCrs][Grade];
bool payment;
};
but when I try to take the two constants out of the struct Student
scope the error does not appear any more
const int MaxNrOfCrs = 10; // The error vanishes here
const int Grade = 1; // The same error vanishes here also
struct Student{
string name;
string birthday;
int studyYear;
string Faculty;
string Department;
Course crs[MaxNrOfCrs][Grade];
bool payment;
};