April 24th, 2003, 05:06 AM
Join Date: Apr 2003
Location: Manchester, England
Using static modifier with template classes
Does anyone have experience of the following? The member attribute counter is declared static so I can keep track of how many variables are in existence. However, this means that it isn't actually defined yet, right?
To do that I have to declare it outside of the class. If this much is true, then the problem I'm having is getting the syntax right on the line that I've commented out, because things are confused by the template <> stuff.
Quite new to this part of C++. Any help much appreciated!
// Class to store variable information.
template <class PType> class variable
// Counter to ensure maximum limit of variables not breached.
static int counter;
// Variable name and value.
variable(char *n, PType v);