Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6194073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:14:01+00:00 2026-05-24T03:14:01+00:00

There is a base class: template<class T_CLASS> class TBase { protected: static CSomeClass m_objSomeClass;

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:14:02+00:00Added an answer on May 24, 2026 at 3:14 am
    template<>
    CSomeClass TBase<CSub1>::m_objSomeClass;
    template<>
    CSomeClass TBase<CSub2>::m_objSomeClass;
    

    is the one of the correct ways, if you want to explicitly have static member defined for a solid class like CSub1, CSub2. Demo.

    Edit: The conventional way is to define as:

    template<class T_CLASS>
    CSomeClass TBase<T_CLASS>::m_objSomeClass;
    

    Both ways would serve the purpose.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider: template <typename T> class Base { public: static const bool ZEROFILL = true;
Let's say we have these two classes: public class Base { public static int
Example: template<class T> class Base { public: Base(); friend class T; }; Now this
I am trying to use template meta-programming to determine the base class. Is there
Are there any dictionary classes in the .NET base class library which allow duplicate
Is there anyway to discover the base class of a class in Python? For
Is there a better way of binding a list of base class to a
Let's say I have a Base class and several Derived classes. Is there any
In VB.NET there is a keyword 'shadows'. Let's say I have a base class
Consider these classes. class Base { ... }; class Derived : public Base {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.