c++ question

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
schick
Posts: 230
Joined: Tue Oct 07, 2003 3:55 pm
Location: Germany
Contact:

c++ question

Post by schick »

Shame on me, having problems with the c++ syntax.

The problem:
I have a singleton template like (thats not the problem :-)):

Code: Select all

template <class T>
class TSingleton 
{
protected:
	TSingleton()
	{
	};

    TSingleton(const TSingleton&)
	{
	}; 

    TSingleton& operator=(const TSingleton&)
	{
		return *this;
	};

public:
	virtual ~TSingleton()
	{
	};
	
	static T* getInstance()
	{
		static T Instance;
		return &Instance;
	};
}; 
What i want to have is a map like:

Code: Select all

std::map< int, TSingleton*> SingletonMap;
But in fact i do not have any ideas how to implement that?
Coolkat
Posts: 25
Joined: Sun Mar 28, 2004 1:44 am
Location: U.S.A.

Post by Coolkat »

try this:

Code: Select all

#include <iostream>
#include <map>

using namespace std;

Template <class T>
class TSingleton 
{
  public: 
  TSingleton();
  ~TSingleton();
 
  private:
  static int something;
};

int main()
{
   map<int , TSingleton<T>> some_map;
   //do stuff with the map
   return 0;
}
that should be what your looking for
IcePump Gaming
under construction
Post Reply