(please tell me if this doesn't make sense)
First, a little background
I initialized an array of classes using this:
Code:
Room roomArray[20][30]; //class declaration already done, dont worry 'bout that
Works great.
Then i created a function that initializes the elements with the values i give... like this...
Code:
Room temp1(3, 5, false, true, false, true, "A Dirt Trail", "Very dusty");
roomArray[3][5] = temp1;
Room temp2(3, 6, false, false, false, true, "A Dirty Trail", "whatever");
roomArray[3][6] = temp2;
1) Is there a way to initialize an element of the array without making that temp object?
I tried doing this...
Code:
roomArray[3][5](3, 5, false, true, false, true, "Dirty Trail", "blabla") // doesn't work
2) Why doesn't that 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[3][5] = temp;
temp(new arguments);
roomArray[3][6] = temp;