00001 00002 // Smart Pointer "package" 00003 // allow the creation of an array of void* 00004 // that you can delete using the right destructors. 00005 // 00006 // Authors : C.Delaere, O. van der Aa 00007 // 00009 00010 #ifndef _SMARTPOINTER_H_ 00011 #define _SMARTPOINTER_H_ 00012 00014 00017 class smart_void 00018 { 00019 public: 00020 virtual void* theaddr() = 0; 00021 virtual ~smart_void() {} 00022 }; 00023 00025 00028 template<class T> 00029 class smart_type: public smart_void 00030 { 00031 public: 00032 smart_type(unsigned int size = 1) {addr = new T[size];} 00033 ~smart_type() {delete [] addr;} 00034 void* theaddr() {return addr;} 00035 void* theptr() {return &addr;} 00036 private: 00037 T* addr; 00038 }; 00039 00040 #endif