How to declare the second parameter as optional?
template <typename T>
inline void Delete (T *&MemoryToFree,
T *&MemoryToFree2 = ){
delete MemoryToFree;
MemoryToFree = NULL;
delete MemoryToFree2;
MemoryToFree2 = NULL;
}
I tried several things after the = operator, for example NULL, (T *) NULL, etc. Can this be done?
The only way the compiler allowed me to do this is to use overloading ...
template <typename T, typename T2>
inline void Delete (T *&MemoryToFree, T2 *&MemoryToFree2){
delete MemoryToFree;
MemoryToFree = NULL;
delete MemoryToFree2;
MemoryToFree2 = NULL;
}
source
share