Array's

This is a discussion on Array's within the C++ Programming forums, part of the General Programming Boards category; How can we create an array of object, calling a defined user constructor, like this: tab = new MyClass [n] ...

  1. #1
    Unregistered
    Guest

    Array's

    How can we create an array of object, calling a defined user
    constructor, like this:
    tab = new MyClass [n] ( arg1, argn );
    ?
    I know it's possible with gcc, but with MS Visual C++,
    I'm afraid to think it's not possible!
    Is there a better way than create an array of pointer of objects?

    Thanks!

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    I don't see what the problem would be. I just use:

    Code:
    //sample
    #include "MyClass.h"
    
    //array of 12 of your objects
    CMyClass cmDebug[12];
    
    //pointer to one of them
    &cmDebug[0];

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    class MyObject;


    MyObject **Objects;

    MyObject *ptrList=*Objects;


    Is this what you want?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function to read in two arrays
    By ssmokincamaro in forum C Programming
    Replies: 7
    Last Post: 11-12-2008, 06:59 AM
  2. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 03:24 PM
  3. Replies: 16
    Last Post: 01-01-2008, 03:07 PM
  4. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 09:47 PM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 08:24 PM

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