GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 03-Jul-2008, 12:18
dreamuser dreamuser is offline
New Member
 
Join Date: Jun 2008
Posts: 5
dreamuser is an unknown quantity at this point

How to allocate memory for a double pointer


I have the following:

BoundedQueue<Item> * * Body;

How do I allocate memory for Body?

Body = new BoundedQueue<Item>* does not work
  #2  
Old 03-Jul-2008, 12:53
ocicat ocicat is offline
Regular Member
 
Join Date: May 2008
Posts: 580
ocicat is a jewel in the roughocicat is a jewel in the rough

Re: How to allocate memory for a double pointer


Quote:
Originally Posted by dreamuser
Body = new BoundedQueue<Item>* does not work
It would help if you provide both the error received & what is the purpose of Body. Are you simply wanting an array of pointers, a two-dimensional array, or what? Likewise, what compiler are you using?

The following compiles as expected with GCC 3.3.5:
CPP / C++ / C Code:
template <class T> class foo { };

class bar { };

int 
main() {
    foo<bar> **pp = new foo<bar>*;
    
    return 0;
}
...which simply allocates space for a pointer dynamically.
 
 

Recent GIDBlogProgramming ebook direct download available by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Powell Method EngineerFORhire C Programming Language 5 01-Oct-2005 01:34
[Tutorial] Pointers in C (Part II) Stack Overflow C Programming Language 0 27-Apr-2005 18:36
[Tutorial] Pointers in C (Part I) Stack Overflow C Programming Language 1 08-Apr-2005 19:35
Double output leanieleanz C++ Forum 1 11-Mar-2005 21:19

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:56.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.