vector of std::string reported as leaks

This is a discussion on vector of std::string reported as leaks within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by Bubba Code: class Console { public: static void createInstance(); static Console* getInstance(); ... ... private: Console(); virtual ...

  1. #16
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Quote Originally Posted by Bubba View Post
    Code:
    class Console
    {
           public:
            static void createInstance();
            static Console* getInstance();
     
            ...
            ...
     
        private:
            Console();
            virtual ~Console();
            Console(const Console &obj);
            Console& operator = (const Console &obj);
            std::list<std::string> m_Messages;
            ...   
            ...
     
    };
    That's about all that needs shown. createInstance() is called during setup() which is called from the main process. After that getInstance() is used. Upon shutdown the destructor calls clear on m_Messages. Fairly straightforward, somewhat modified, singleton pattern.
    VS2008 complains about private constructors/destructors
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  2. #17
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    Ok. So is it saying the compiler cannot clean up the instance b/c it is private?? The whole singleton pattern relies on it. I don't think visibility of the dtor/ctor applies to the compiler cleaning up statics at program exit.
    Last edited by VirtualAce; 11-05-2008 at 08:07 PM.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 08:54 AM
  2. Replies: 13
    Last Post: 12-14-2007, 03:34 PM
  3. Improving my code
    By rwmarsh in forum C++ Programming
    Replies: 14
    Last Post: 07-08-2006, 12:18 PM
  4. Debugging help
    By cuddlez.ini in forum C++ Programming
    Replies: 3
    Last Post: 10-24-2004, 08:08 PM
  5. DLL and std::string woes!
    By Magos in forum C++ Programming
    Replies: 7
    Last Post: 09-08-2004, 01:34 PM

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