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 8988303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:59:24+00:00 2026-06-15T21:59:24+00:00

I am trying to Initialize a Non-Integral template Constant. Please find below the code:

  • 0

I am trying to Initialize a Non-Integral template Constant.

Please find below the code:

#ifndef _EXETENDED_CLASS_H
#define _EXETENDED_CLASS_H


template<class T>
class BaseClass
{
            public:
                   BaseClass();
                   ~BaseClass();


};

template <class T>
BaseClass<T>::BaseClass()
{}

template <class T>
BaseClass<T>::~BaseClass()
{}



template<class T>
class ExtendedClass:public BaseClass<T>
{
            public:
                   typedef ExtendedClass<T>* position;
                   static const position NULLPOSITION;

                   ExtendedClass();
                   ~ExtendedClass();


           private:

                   position _successivo; 
};


template<class T>
const  ExtendedClass<T>::position ExtendedClass<T>::NULLPOSITION = 0;

template <class T>
ExtendedClass<T>::ExtendedClass()
{}

template <class T>
ExtendedClass<T>::~ExtendedClass()
{}

#endif

The problem lies with the lines

template<class T>
const  ExtendedClass<T>::position ExtendedClass<T>::NULLPOSITION = 0;

I cannot initializa the constant inline as it is of a Non-Integral Type.

From what i have read online it appears that if I moved the const initialization in a .cpp file, the issue would be gone. However I can’t do that as I am dealing with a templated class.
I get errors as detailed below:

ExtendedClass.h:43: error: expected init-declarator before "ExtendedClass"
ExtendedClass.h:43: error: expected `;' before "ExtendedClass"
make: *** [ExtendedClass.o] Error 1

Can someone please have a look at it for me, please? Thank you very much in advance for yout time.

  • 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-06-15T21:59:25+00:00Added an answer on June 15, 2026 at 9:59 pm

    You’ve written the type twice, and didn’t qualify the identifier. No wonder the poor compiler is confused.

    template<class T>
    const  ExtendedClass<T>::position ExtendedClass<T>::NULLPOSITION = 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm having hard time trying to understand how interrupts work. the code below initialize
Trying to initialize and set things up for a class as follows: class Accel
I am trying to compile this code: class OthelloState { public: // constructor Othello(int
I'm trying to add a static constant variable to my class, which is an
I'm trying to create a template class that stores a function pointer to a
I am trying to implement web browser using Swing. Here is code below. import
I am trying to define a class Util with a static member variable MAX_DIST,
I am trying to initialize a vector which has integers 1 to n in
I'm trying to initialize a Datatable with a default search value that the user
I'm trying to initialize a usercontrol that contains a gridview as hidden when a

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.