Answer the question
In order to leave comments, you need to log in
How to create operator= for Template class?
Hello.
I have a SearchVector class Let's
say I want to do the following. Find the largest element from value and return it for initialization
I need an equalization operator.
SearchVector <double> sv1({ 1.0, 1.9, 12.0, 2.5, 3.4 });
SearchVector <int> sv2({ 1, 2, 5, 23, 2, 1 });
double max_double = sv1;
int max_int = sv2;
T & operator=(SearchVektor<T> & s ) {
//// Find max from s
return (T) max;
}
A1.cpp:189:26: error: cannot convert 'SearchVektor' to 'double' in initialization
T& T::operator=(T arg) // copy/move constructor is called to construct arg
{
swap(arg); // resources are exchanged between *this and arg
return *this;
} // destructor of arg is called to release the resources formerly held by *this
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question