Thread: Array's

  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
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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, 07:59 AM
  2. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 04:24 PM
  3. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  4. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 10:47 PM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 09:24 PM