i have object
template <class FLOAT>
struct Cstruct {
Struct1<FLOAT> _var1;
Struct2<FLOAT> _var2;
Cstruct(){};
Cstruct(Struct1 var1,Struct2 var2):_var1(var1),_var2(var2){};
};
FLOAT can be "double" or "int". Struct1 and Struct2 are also templatized with FLOAT.
now i also have a global variable declared
Cstruct<double> globalObj_d;Cstruct<int> globalObj_i;
inside main() i have
main(){
// some code
if double then call func<double>();
if int then call func<int>();
}
and inside templatized func() i have
template<class FLOAT> void func(){
// some code
Struct1<FLOAT> var1;
Struct2<FLOAT> var2;
Cstruct<FLOAT> localObj(var1,var2);
// now i want to assign "localObj" to the global object "globalObj_d"
if double then
globalObj_d = localObj;
if int then
globalObj_i = localObj;
}
and i get an error saying
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Cstruct<FLOAT>
does does this mean i have to explicitly write an "operator=" inside Cstruct ? my understading of templatized and global object it seems is kind of flawed. any help will greatly appreciated.