Sign in to follow this  
hahaha

c++ Struct Question

Recommended Posts

Yes, it's possible.

struct TheStruct
{
static TheStruct & Instance()
{
static TheStruct instance;
return instance;
}

private:
TheStruct();
TheStruct(const TheStruct &);
};


There's a very high probability that doing this is useless (i.e. you don't need the protection), and a high probability that your design will cause you great pain in a few weeks or months.

Share this post


Link to post
Share on other sites
A singleton or similarly a monostate.

*A monostate allows multiple instances but all instances share the same state.

[edit]

You could probably avoid both however.

[Edited by - fpsgamer on August 5, 2007 10:19:27 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this