H
hurcan solter
I have an host class that holds fundamental types
template<typename T>
struct Generic{
Generic(T val= T()):mval(val){}
operator T(){return mval
T mval;
}
template<typename T1,typename T2>
Generic<T1 or T2 ???>operator+(const Generic<T1>& lhs,const
Generic<T2>& rhs)
{
return Generic<T1 or T2 ???>(lhs.mval+rhs.mval);
}
Is there a compelling reason to discard the conversion operator and
define overloaded arithmetic operators because they are considered
dangerous?I'd like that class to behave like fundamental types.but i
dont want to overload every operator over there . what are the issues
i should be aware of if i stick with the user defined conversion
operator?
thanks a lot
hurcan....
template<typename T>
struct Generic{
Generic(T val= T()):mval(val){}
operator T(){return mval
T mval;
}
template<typename T1,typename T2>
Generic<T1 or T2 ???>operator+(const Generic<T1>& lhs,const
Generic<T2>& rhs)
{
return Generic<T1 or T2 ???>(lhs.mval+rhs.mval);
}
Is there a compelling reason to discard the conversion operator and
define overloaded arithmetic operators because they are considered
dangerous?I'd like that class to behave like fundamental types.but i
dont want to overload every operator over there . what are the issues
i should be aware of if i stick with the user defined conversion
operator?
thanks a lot
hurcan....