Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++: Compile Error for Template Assignment Operator Overloading

Tags:

c++

I keep getting the error "use of class template requires template argument list" when I compile the following code in VC++6. What is wrong with it?

template <class T>  
class StdVector{  
    public:                 
        StdVector & operator=(const StdVector &v);
};

template <typename T>  
StdVector & StdVector<T>::operator=(const StdVector &v){  
    return *this;
}
like image 993
Lopper Avatar asked Jan 30 '26 03:01

Lopper


1 Answers

You need to put the template parameter in the return type:

template <typename T>  
StdVector<T> & StdVector<T>::operator=(const StdVector &v)
{  
    return *this;
}
like image 195
CB Bailey Avatar answered Jan 31 '26 19:01

CB Bailey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!