Hi I'm making a structure to hold the sales of units per month by a salesman, but when I try to Initializing array for sales I get an error:
IntelliSense: data member initializer is not allowed
Can someone explain what the problem is.
Here the code for my structure:
1 2 3 4 5 6 7 8
|
struct SalesRec
{
int salesNo;
char Forename[20], Surname[20];
int Sales[12] = { };
double average;
double bonus;
};
|
Last edited on
You cannot have initializer for class data members, unless you are using C++14.
Until then, you need to do all work in constructor.
So I would have to put it within the function then for it work?
Yes. Create constructor for your class and do all initialization here.
Ok Thanks for the help :D