Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
providing classes
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Matthias Kaeppler, post: 2521311"] If it must not be created twice, and if it's shared by many classes, then this screams for making TUsers a singleton. class TUsers { public: static TUsers& instance(); ... private: TUsers(); // make ctor private }; inline TUsers& TUsers::instance() { static TUsers tu; return tu; } Now you can acquire a handle to the one and only TUsers object everywhere you include the TUsers header: .... TUsers& tu = TUsers::instance(); tu.foobar(); .... [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
providing classes
Top