/* -*- C++ -*- */ /************************************************************************* * Copyright(c) 1995~2005 Masaharu Goto (root-cint@cern.ch) * * For the licensing terms see the file COPYING * ************************************************************************/ #ifdef __hpux #include #else #include using namespace std; #endif template class A; A *pa; template class A { T* p; public: A() ; void set(T in) ; ~A(); void disp() ; }; //A *pa; A *pb; template A::A() { p=0; } template A::~A() { if(p) delete p; } template void A::set(T in) { if(p) delete p; p=new T(in); } template void A::disp() { if(p) { cout << *p << endl; } } A c; int main() { A d; pa=new A; pa->set(0xfffff); pb=new A; pb->set(3.1416); c.set(123); d.set(0xfff); pa->disp(); pb->disp(); c.disp(); d.disp(); delete pb; delete pa; return 0; }