tags:

views:

55

answers:

1

http://www.adp-gmbh.ch/cpp/templates/static_members.html makes it clear what I need to do - if the template has a single parameter.

What if it had two?

template <typename T, typename T2> class X {
  public:
     static int st_;
 };

How would I template the static memebr data?

template <typename T, typename T2> int, int X<T, T2>::st_;

or

template <typename T, typename T2> int int X<T, T2>::st_;

or what?

I think that my problem is knowinng what to do with the two real types (both int here).

After templating, how do I declare my static member variable?

+4  A: 
template <typename T, typename T2>
int X<T, T2>::st_;

You don't need two int-s. The int is the just type of st_.

KennyTM
D'oh!! Thanks. Can you tell me how I initialize the static member var? `int X<int, int>::st_= 0;` doesn't seem to be correct.Aha!! http://c2.com/cgi/wiki?TooFewTemplateParameterLists shows that *with g++*, I need `template <> int X<int, int>::st_= 0;` just in case anyone is wondering
Mawg