Overloading << and >> in C++ to perform decimal shifts -
i trying overload << , >> operators perform decimal shifts, i'm not seeing how that. example, i'll have member function of class myclass
myclass myclass::operator<<(myclass ob2) { //code in here overloading << //in object, there float value perform shift on }
any appreciated! thanks!!!
presumably "decimal shift" means shifting decimal point left (right, operator>>
) specified number of digits.
in case, want parameter unsigned int:
myclass &myclass::operator<<(unsigned digits) { value *= pow(10, digits); return *this; }
Comments
Post a Comment