Set struct value

Is it possible to have a struct with an initial value?


For example:
1
2
3
4
5
typedef struct theatre{
       string showName;
       int stallSeats;
       int stallSeatRem = 500;
       }t;


This code doesn't work but it might help describe my problem better.

I am also using a text file to store the information but I want it so that the first time the program is run it creates the file with an inital value for the total number of seats remaining.

How would I go about this?

Thanks
No, not like this. You need to make constructor, like in class. As struct is the same as class. And in class you can't assign a value to variable.
So it seems to me.
Last edited on
Topic archived. No new replies allowed.