The first thing is, I was making this program in the school, and so I must use Turbo C++.
This is how my code is (somewhat):
1 2 3 4 5 6
struct X
{
char a[64];
char b[64][4];
int x;
};
And I am making an array, using the format:
1 2 3 4
X abc[]=
{
{"a", {"a","b","c","d"},1}
};
When I compile it, I get the Too Many reinitializers error.
As far as I can see, this ought to work, even in Turbo C++. I have tested it in Visual C++, and it worked.
The thing was that even my teacher agreed that it shouldn't be giving that error. But, is there an alternative for declaring an array without doing this?
Actually, this was just one for the sake of representing it. I intend for it to be expandable.
I was thinking about it and I think making a function to set the values might work. I will try it tommorrow, and ask again if I need some more help.
Many thanks!
I was thinking about it and I think making a function to set the values might work.
If there are default values to be used every time, then you should write a constructor that does this. Otherwise, write a member function that does this (commonly called a "setter", particularly by Java coders).
I intend for it to be expandable.
Then use a vector. vector<X> abc; // expands as needed without you having to worry about it
I question the use of deliberately learning pre-standard C++ from twenty years ago. If you have the option of learning actual C++ instead, you should switch to that.
C++ was one of the optional subjects in the school. I took it because I had sufficient knowledge of C++ already, from reading from this site, and then from C++ primer plus.