Thread: Dynamically allocate a pointer?

  1. #1
    Registered User
    Join Date
    Mar 2006
    Location
    IL
    Posts
    23

    Dynamically allocate a pointer?

    I am working on something to basically hold references to several objects. So the plan was something like this:

    Code:
    obj **cPList=new *obj[30];
    However I get compiler errors when I try this. Can anyone tell me how to dynamically allocate pointers?

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Code:
    obj **cPList=new obj*[30];

  3. #3
    Registered User
    Join Date
    Mar 2006
    Location
    IL
    Posts
    23
    Quote Originally Posted by Tonto
    Code:
    obj **cPList=new obj*[30];
    Thank you.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    How about
    Code:
    obj **cPList=new obj*[30];
    Next time, post your error message(s) as well, along with which OS and compiler you're using.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ban pointers or references on classes?
    By Elysia in forum C++ Programming
    Replies: 89
    Last Post: 10-30-2007, 03:20 AM
  2. sorting with pointer of pointers to array
    By dunpealslyr in forum C++ Programming
    Replies: 6
    Last Post: 10-01-2007, 11:26 PM
  3. Question About Pointer To Pointer
    By BlitzPackage in forum C++ Programming
    Replies: 2
    Last Post: 09-19-2005, 10:19 PM
  4. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  5. Could somebody please help me with this C program
    By brett73 in forum C Programming
    Replies: 6
    Last Post: 11-25-2004, 02:19 AM