Object pointers and Templates

This is a discussion on Object pointers and Templates within the C++ Programming forums, part of the General Programming Boards category; Hi Just a quick question: How do i use a pointer on such an object instantiation like so: Code: Lattice<Juxtacrine> ...

  1. #1
    Registered User ventolin's Avatar
    Join Date
    Jan 2004
    Posts
    92

    Question Object pointers and Templates

    Hi Just a quick question:

    How do i use a pointer on such an object instantiation like so:

    Code:
    Lattice<Juxtacrine> l(width,height);
    I want to be able to do the following sort of thing:

    Code:
    Lattice<Juxtacrine> *l(width,height) = new Lattice<Juxtacrine>;
    Is this possible? I need to be able to delete and re-create this object eg delete l; and the only way i can think of doing this is via pointers? am i correct?

    Regards,

  2. #2
    Registered User ventolin's Avatar
    Join Date
    Jan 2004
    Posts
    92
    Dont worry, i didnt need to do this..

  3. #3
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Anyway, here's how it's done:
    Code:
     
    Lattice<Juxtacrine>* l = new Lattice<Juxtacrine>(width,height);
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Queue with templates
    By pobri19 in forum C++ Programming
    Replies: 6
    Last Post: 09-23-2008, 06:06 AM
  2. Vectors of pointers and function templates
    By 7words in forum C++ Programming
    Replies: 3
    Last Post: 05-02-2004, 11:39 AM
  3. Templates and pointers
    By Trauts in forum C++ Programming
    Replies: 7
    Last Post: 02-26-2003, 04:33 PM
  4. templates with pointers
    By Cipher in forum C++ Programming
    Replies: 3
    Last Post: 11-18-2002, 10:45 AM
  5. tracing pointers
    By makimura in forum C++ Programming
    Replies: 3
    Last Post: 11-02-2001, 08:55 AM

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