Thread: array of objects

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    1

    array of objects

    how do i remove from and add objects into an array of objects at a specific index?
    i'm very new to c++ and was just wondering if there was an easy way to do this,

    thanks

  2. #2
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    there is nothing spacial. Just use assignement
    Code:
    class t {
    public:
       t(int xx=0 ):x(xx){}
    private:
       int x;
    };
    
    int main() {
        t tarr[20];
        t some_t(3);
        tarr[5] =some_t; 
    }
    Kurt

  3. #3
    Advanced Novice linucksrox's Avatar
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    198
    If you're asking about an array that is only as big as the number of elements you have in it, you can probably use a vector.
    "What are all you parallelograms doing here?" - Peter Griffin (to Joe and his wheelchair buddies)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  2. question about multidimensional arrays
    By richdb in forum C Programming
    Replies: 22
    Last Post: 02-26-2006, 09:51 AM
  3. Replies: 4
    Last Post: 10-16-2003, 11:26 AM
  4. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM
  5. Adding objects to an array
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 11-27-2001, 09:24 AM