Help regarding Error in declaring an array of struct

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.

Any help?
Turbo C++ is over twenty years old and dates from long before C++ was standardised. I wouldn't be surprised if it just didn't support this.
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?
But, is there an alternative for declaring an array without doing this?


You can just declare an array of size one.

X abc[1];
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
But again, Turbo C++ is the spanner in the works! It doesn't even support templates fully. Neither does it have vectors!
Why exactly are you using it, again? It clearly can't be used to learn C++.
To Quote my teacher:
"Most of the books available are on Turbo C++, and it will be hard for the students to learn without a reference book".
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.
Topic archived. No new replies allowed.