|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
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 |
#2
| |||
| |||
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. |
#3
| |||
| |||
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; } |
#4
| |||
| |||
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). |
![]() |
|
Tags: classinfo, static members, static pointer, template classes |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Listing members of Group with >1500 members | Umesh Thakur | Windows Server Help | 11 | 03-02-2012 05:29 AM |
Where can I find bank check template for Microsoft Word or Template | aMADeO! | MS Office Support | 2 | 28-01-2012 03:50 PM |
Display members of a group with more than 1500 members | Simon G | Windows Server Help | 5 | 25-10-2011 12:35 PM |
Java example for static members | ScarFace 01 | Software Development | 6 | 05-01-2010 05:14 AM |
What is static data members of class? | Jaiwanti | Software Development | 3 | 20-11-2009 10:48 AM |