Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

How can I make a Class be instantiated only ONCE?

$
0
0
Supposedly, I have class called MyClass. MyClass manages multiple widgets of the same kind and SHOULD be the only one managing these widgets. What I want to achieve is “analogous” to this thread [stackoverflow.com] but in a way that it is just a “Class” and not an application. The reason for this is that when I instantiate MyClass as: MyClass mc; “mc” will be the only one “MONOPOLIZING” the set of widgets. Doing this: MyClass mc1; \\ok MyClass mc2; \\invalid MyClass mc3; \\invalid and so on .... The RESTRICTION is that MyClass doesn’t have any ctor or dtor so I don’t think I can do a “hack” with QSharedMemory or something. Help Please. Thanks!

Viewing all articles
Browse latest Browse all 18427

Trending Articles