[SOLVED] template<> question

Get answers to all your basic programming questions. No Ogre questions, please!
iblues1976
Gnome
Posts: 379
Joined: Fri Sep 16, 2011 4:54 pm
x 10

[SOLVED] template<> question

Post by iblues1976 »

I'm working on advanced ogre framework tutorial

http://www.ogre3d.org/tikiwiki/Advance ... ework.cpp

I want to see if I have this correct:

Code: Select all

template<> OgreFramework* Ogre::Singleton<OgreFramework>::ms_Singleton = 0;
Here, is defining the OgreFramework pointer to be singleton and =0 is making it constant?

thanks,
Francisco
Last edited by iblues1976 on Thu Jan 19, 2012 9:41 pm, edited 1 time in total.
User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!
x 8

Re: template<> question

Post by Brocan »

Singleton means one unique instance for a class. This pointer to the created instance is stored in the var "ms_Singleton". This var is static in the Singleton template. When you declare a static variable in a class (not only in templates), the var needs to be initialised and declared (due to memory management constraints) in the cpp.

So, in this line you are declaring the var and initialising it to 0 (null pointer).