🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Benjamin Scherrey Fri, 12 Jan 1996 18:05
Re: Initialization of Static Components of a Template Class
#3009
Author: Benjamin Scherrey
Date: Fri, 12 Jan 1996 18:05
30 lines
1839 bytes
In message <4cr2m1$1kcq@news.gate.net> - solution@gate.net (Ken Walter) writes:
:>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! 

	Very true - this is most inconvenient but has been required by every 
compiler I've used. It *is* my understanding, however that the following code 
(and your example above) are officially supported so compilers should be 
letting us do this Real Soon Now. 

--- code ----

template< class T > int SOMEClass< T >::AStatic;	// Note - statics are
							// initialized to zero
							// or their equivalent.
							// Don't put an explicit 0
							// in your templates!
--- end code ---

	Regards,

		Ben Scherrey
		scherrey@proteus-tech.com
---
[ 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