There is a base class:
template<class T_CLASS>
class TBase
{
protected:
static CSomeClass m_objSomeClass;
public:
inline void Set(CSomeClass f_objSomeClass) { m_objSomeClass = f_objSomeClass; }
};
And there are some sub classes which all shall have their own static member m_objSomeClass. I try to do this by templating the base class.
class CSub1 : public TBase<CSub1>
{
//...
};
class CSub2 : public TBase<CSub2>
{
//...
};
What does the definition for this look like? Is it even possible? I tried some… but none worked:
template<class T_CLASS>
CSomeClass TBase<T_CLASS>::m_objSomeClass;
//In fact the next one worked in Visual Studio;
// but not in with the armcc where I need it.
CSomeClass TBase<CSub1>::m_objSomeClass;
CSomeClass TBase<CSub2>::m_objSomeClass;
Any suggestions? Thanks, Mirco
is the one of the correct ways, if you want to explicitly have
staticmember defined for a solid class likeCSub1,CSub2. Demo.Edit: The conventional way is to define as:
Both ways would serve the purpose.