Thread: Question for class- & array-savvy people

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User GrNxxDaY's Avatar
    Join Date
    Jul 2002
    Posts
    140

    Arrow Please help?

    (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;
    Last edited by GrNxxDaY; 07-25-2002 at 11:44 PM.
    AOL: GrNxxDaY
    IDE: Dev-C++ Beta 5 (v4.9.4.1)
    Project: Eye of Sahjz (text-RPG)
    If you think I may need help, please IM me.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dynamic Mutli dimensional Array question.
    By fatdunky in forum C Programming
    Replies: 6
    Last Post: 02-22-2006, 07:07 PM
  2. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM
  3. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM
  4. Religious Bull****
    By Witch_King in forum A Brief History of Cprogramming.com
    Replies: 119
    Last Post: 10-23-2001, 07:14 AM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM