As @KerrekSB mentioned in the comment, this is a bad coding style.
What the author is trying to do is to avoid compile-time warnings to compare pointers of different types, such as a type Stack<int>*pointer and a type pointer Stack<double>*.
It can be easily avoided by using overloads.
template<typename T>
Stack<T>& operator=(const Stack<T> & op2){
if (this == &op2){
return *this;
}
}
template<typename T>
template<typename T2>
Stack<T>& operator=(const Stack<T2> & op2){
}
source
share