Hi all! I have the following class CppProperty class that holds value:
template<typename TT>
class CppProperty
{
TT val;
public:
CppProperty(void)
{
}
CppProperty(TT aval) : val(aval)
{
}
CppProperty(const CppProperty & rhs)
{
this->val = rhs.val;
}
virtual ~CppProperty(void)
{
}
TT operator=(TT aval)
{
this->val = aval;
return this->val;
}
friend TT operator++(CppProperty & rhs);
friend TT operator--(CppProperty & rhs);
friend TT operator++(CppProperty & rhs, int);
friend TT operator--(CppProperty & rhs, int);
//template<typename RR>
//friend RR operator=(RR & lhs, const CppProperty & rhs);
//friend int & operator=(int & lhs, const CppProperty & rhs);
//int reinterpret_cast<int>(const CppProperty & rhs);
};
I want to do assignment like this:
CppProperty<char> myproperty(10);
myproperty++;
int count = myproperty;
How this can be done? I can't override the operator=. Any help is greatly appreciated! Thank you!