How to initialize static members in template classes
I have a class inherited from Class CLASSTYPE <T> classes that are templates.
Now, inside each CLASSTYPE <T> is called a static pointer, which is initialized to NULL value, (is it possible to achieve this).
Theoretically we could do this, to find each value, and as well to initialize the static member to NULL ...
I tried to move the definition of header which no longer gives error when we try to create the class, but with an error could we try to use classInfo.
Thanks
Re: How to initialize static members in template classes
I can't really say that it will run using the a pointer but I would speculate it because it's unable to calculate the size of the template class because we then knowns the size of the template parameter and hence the size of the class.. Making "registrar" a pointer which may solves the problem, regardless of what the template parameter might be.
Re: How to initialize static members in template classes
Below here I am providing you some code for the template classes,just try to run it using it.
Code:
#include <stdio.h>
#include <conio.h>
template< typename T >//here you will declare your template
class Test
{
public:
temp( const exa1 & id ) : A_id(id){ }
private:
exa1 A_id;
static int tecldh_count;
};
int Test< float >::s_count = 0;
int main( int argv, char *argv[] )
{
Temp< float > temp( 1.0f );
return 0;
}
Re: How to initialize static members in template classes
My initial guess is that template static data member is either to initialized before the first use by any module whatever may be implemented in the program or int already initialized module (and that may be too late for using it by other external static object).