(please tell me if this doesn't make sense)
First, a little background
I initialized an array of classes using this:
Works great.Code:Room roomArray; //class declaration already done, dont worry 'bout that
Then i created a function that initializes the elements with the values i give... like this...
1) Is there a way to initialize an element of the array without making that temp object?Code:Room temp1(3, 5, false, true, false, true, "A Dirt Trail", "Very dusty"); roomArray = temp1; Room temp2(3, 6, false, false, false, true, "A Dirty Trail", "whatever"); roomArray = temp2;
I tried doing this...
2) Why doesn't that work?Code:roomArray(3, 5, false, true, false, true, "Dirty Trail", "blabla") // doesn't work
Also, i can't initialize other elements without creating new temporary variables (e.g., Room temp1; Room temp2
Doing this will make the RAM needed to create all those Room objects double.
3) is there a better way?
(won't let me re-initialize the temp object like this..)
Code:Room temp(arguments); roomArray = temp; temp(new arguments); roomArray = temp;