1 // 2002-05-13 2 3 enum region { oriental, egyptian, greek, etruscan, roman }; 4 keepalive(bool * var)5void keepalive(bool *var) { } keepalive_int(int * var)6void keepalive_int (int *var) { } 7 8 // Test one. 9 class gnu_obj_1 10 { 11 protected: 12 typedef region antiquities; 13 static const bool test = true; 14 static const int key1 = 5; 15 static long key2; 16 17 static antiquities value; 18 19 public: gnu_obj_1(antiquities a,long l)20 gnu_obj_1(antiquities a, long l) {} ~gnu_obj_1()21 ~gnu_obj_1() {} 22 method()23 long method () 24 { 25 static int sintvar = 4; 26 static bool svar = true; 27 28 keepalive (&svar); 29 keepalive_int (&sintvar); 30 return key2; 31 } 32 }; 33 34 // An object with a single constructor. 35 class single_constructor 36 { 37 public: single_constructor()38 single_constructor () { } ~single_constructor()39 ~single_constructor () { } 40 }; 41 42 const bool gnu_obj_1::test; 43 const int gnu_obj_1::key1; 44 long gnu_obj_1::key2 = 77; 45 gnu_obj_1::antiquities gnu_obj_1::value = oriental; 46 47 48 // Test two. 49 template<typename T> 50 class gnu_obj_2: public virtual gnu_obj_1 51 { 52 public: 53 static antiquities value_derived; 54 55 public: gnu_obj_2(antiquities b)56 gnu_obj_2(antiquities b): gnu_obj_1(oriental, 7) { } 57 }; 58 59 template<typename T> 60 typename gnu_obj_2<T>::antiquities gnu_obj_2<T>::value_derived = etruscan; 61 62 // Test three. 63 template<typename T> 64 class gnu_obj_3 65 { 66 public: 67 typedef region antiquities; 68 static gnu_obj_2<int> data; 69 70 public: gnu_obj_3(antiquities b)71 gnu_obj_3(antiquities b) { } 72 }; 73 74 template<typename T> 75 gnu_obj_2<int> gnu_obj_3<T>::data(etruscan); 76 77 // 2002-08-16 78 // Test four. 79 #include "m-static.h" 80 81 // instantiate templates explicitly so their static members will exist 82 template class gnu_obj_2<int>; 83 template class gnu_obj_2<long>; 84 template class gnu_obj_3<long>; 85 main()86int main() 87 { 88 gnu_obj_1 test1(egyptian, 4589); 89 gnu_obj_2<long> test2(roman); 90 gnu_obj_3<long> test3(greek); 91 gnu_obj_4 test4; 92 single_constructor test5; 93 94 test4.dummy = test4.elsewhere; 95 test4.dummy = 0; 96 97 test1.method (); // breakpoint: constructs-done 98 99 return test4.dummy; 100 } 101