//stattmpl.cpp
#include <stdio.h>
	//template classes can have static data too
template <class T>
class X	{
public:
   static T a;
   static T* b;
   static int c;
};
	//templated static data is declared much the same way as functions
template <class T>
T X<T>::a;

template <class T>
T* X<T>::b;
	//even when the data type of the variable is not templated,
	//	we must wrap it in a template definition
template <class T>
int X<T>::c;


main()	{
   X<int> intX1;
   X<int> intX2;
   X<float> floatX1;
   X<float> floatX2;

   printf("address of intX1.a=%#x\n",&intX1.a);
   printf("address of intX2.a=%#x\n",&intX2.a);
   printf("address of floatX1.a=%#x\n",&floatX1.a);
   printf("address of floatX2.a=%#x\n",&floatX2.a);

   printf("address of intX1.b=%#x\n",&intX1.b);
   printf("address of intX2.b=%#x\n",&intX2.b);
   printf("address of floatX1.b=%#x\n",&floatX1.b);
   printf("address of floatX2.b=%#x\n",&floatX2.b);

   printf("address of intX1.c=%#x\n",&intX1.c);
   printf("address of intX2.c=%#x\n",&intX2.c);
   printf("address of floatX1.c=%#x\n",&floatX1.c);
   printf("address of floatX2.c=%#x\n",&floatX2.c);
}
//notice in the output there are only two classes created
//	by the above code type1 and type2 of each data type share
//	the same static data elements since they are of the exact
//	same data type
/*** output ***
address of intX1.a=0x1a6
address of intX2.a=0x1a6
address of floatX1.a=0x1ae
address of floatX2.a=0x1ae
address of intX1.b=0x1a2
address of intX2.b=0x1a2
address of floatX1.b=0x1aa
address of floatX2.b=0x1aa
address of intX1.c=0x1a0
address of intX2.c=0x1a0
address of floatX1.c=0x1a8
address of floatX2.c=0x1a8
**************/
