Im trying to create a stack but im receiving errors with overloading my = operator. The stack is of type template. Heres the code
template <typename T>
T& ::stack& operator =(const stack& other)
{
if (this == &other) return *this;
copy(other.stack1[0], other.stack1[other.size], stack1[0]);
return *this;
}
Any help will be appreciated. Thanks
Please try the below signature
template <typename T>
stack<T>& stack<T>:: operator =(const stack<T>& other)
Try:
template <typename T>
stack<T>& stack<T>::operator =(const stack& other)
{
if (this == &other) return *this;
copy(other.stack1[0], other.stack1[other.size], stack1[0]);
return *this;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With