How to create an operator= for Template class?

Hi all.
I have a class SearchVector
Let's say I want to run the following steps. Find greatest value out of ELLEMENT and return it to initialize
I need the operator to be equal.

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;</int></double>


I wrote something like this template for the test, with a break out max of any numbers, but when compiling I receive an error.
How to do it properly ?
T & operator=(SearchVektor<t> & s ) {
 //// Find max from s 

 return (T) max; 
 }</t>


A1.cpp:189:26: error: cannot convert ‘SearchVektor’ to ‘double’ in initialization


Example from cppreference

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
July 4th 19 at 23:59
1 answer
July 5th 19 at 00:01
Solution
Here we must not the assignment operator to override and the cast operator, here is an example.
The fact that lines
SearchVector sv1({ 1.0, 1.9, 12.0, 2.5, 3.4 });
SearchVector sv2({ 1, 2, 5, 23, 2, 1 });
double max_double = sv1;
int max_int = sv2;
I can't change. If I understand You correctly - gay0 commented on July 5th 19 at 00:04
: not necessary, you need to define a cast operator to the type of the template argument, which finds the maximum value in the vector and returns it. This task cannot be solved by overriding the assignment operator. - charity84 commented on July 5th 19 at 00:07
: moreover, there is no assignment, then the implicit call to the constructor. The primitives it is not as if, but the syntax and semantics are the same. - sister58 commented on July 5th 19 at 00:10
: Thank you very much... Everything works as it should, and I have to deal with operator overloading :) - gay0 commented on July 5th 19 at 00:13

Find more questions by tags C++