🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Ken Walter Mon, 08 Jan 1996 23:05
Initialization of Static Components of a Template Class
#2989
Author: Ken Walter
Date: Mon, 08 Jan 1996 23:05
29 lines
1105 bytes

If I have a template class such as:

template<class T> SOMEclass
{
..
private:
static int AStatic;
}


I would like to also be able to say in the header file:

template<class T> int SOMEclass::AStatic(0); 

and have it automaticaly expanded by the compiler with the template class.

Requiring the users of the template class to initialize ever class instance
is very inconvenient!  It almost forces one to use a macro:

#define SOMEclassSTATICS( T )  int SOMEclass<T>::AStatic(0); /
					// other initialization of SOMEclass statics

Or am I missing somrthing from the latest language definition?

Ken Walter

* All the above is hearsay and the opinion of nobody in particular
Re: Initialization of Static Components of a Template Class
#2991
Author: Etay Bogner
Date: Tue, 09 Jan 1996 14:46
20 lines
1278 bytes
In article <4cr2m1$1kcq@news.gate.net>, solution@gate.net (Ken Walter) wrote:

>> template<class T> int SOMEclass::AStatic(0); 

change it to :

template<class T> int SOMEclass<T>::AStatic = 0; // = 0 is clearer for int's
                               ^^^
This is legal for quite some time now, and actually, I don't know why it
passed the moderation, since it's surely a FAQ.

-- 
-- Etay Bogner,
-- Etay_Bogner@mail.stil.scitex.com,
-- Scitex Corp.
-- Israel.
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads