Smart Pointer question

This is a discussion on Smart Pointer question within the C++ Programming forums, part of the General Programming Boards category; How are smart pointers used when the precise type of objects needed are unknown How would a shared_ptr or a ...

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    178

    Smart Pointer question

    How are smart pointers used when the precise type of objects needed are unknown
    How would a shared_ptr or a unique_ptr resolve this? What about the class weak_ptr which is a weak reference to a shared_ptr?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,302
    As in when you have a polymorphic base class, but the exact derived class types will only be known at runtime? The solution is to use a smart pointer of the base class type then.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. COM smart pointer / C++ smart pointer
    By KIBO in forum Windows Programming
    Replies: 1
    Last Post: 02-23-2011, 05:14 AM
  2. smart pointer+allocator?
    By idleman in forum C++ Programming
    Replies: 3
    Last Post: 11-17-2009, 11:51 AM
  3. Which smart pointer to use?
    By leeor_net in forum C++ Programming
    Replies: 4
    Last Post: 04-13-2009, 05:29 AM
  4. Smart pointer class
    By Elysia in forum C++ Programming
    Replies: 63
    Last Post: 11-03-2007, 08:05 AM
  5. pointer and smart pointer address
    By l2u in forum C++ Programming
    Replies: 14
    Last Post: 12-26-2006, 05:00 PM

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