Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 05-05-2009
Member
 
Join Date: Apr 2009
Posts: 65
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
Reply With Quote
  #2  
Old 05-05-2009
Member
 
Join Date: Jan 2009
Posts: 143
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.
Reply With Quote
  #3  
Old 05-05-2009
Member
 
Join Date: Feb 2009
Posts: 105
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;
}
Reply With Quote
  #4  
Old 05-05-2009
Member
 
Join Date: Dec 2008
Posts: 183
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).
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to initialize static members in template classes"
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


All times are GMT +5.5. The time now is 05:24 AM.