array of objects

This is a discussion on array of objects within the C++ Programming forums, part of the General Programming Boards category; how do i remove from and add objects into an array of objects at a specific index? i'm very new ...

  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
    ZuK
    ZuK is offline
    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, 08: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, 12:26 PM
  4. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 01:04 PM
  5. Adding objects to an array
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 11-27-2001, 09:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21