Define conversion functions for converting multiply to int and std::string , as shown in Method 1 or use Method 2 (similar to 1)
Method 1
struct multiply { int t1,t2; operator std::string() { std::stringstream k; k<<(t1*t2); return k.str(); } operator int() { return t1*t2; } multiply(int x, int y):t1(x),t2(y){} };
Method 2
class PS { int _value; public: PS(int value) : _value(value) {} operator std::string() { std::ostringstream oss; oss << _value; return oss.str(); } operator int() { return _value; } }; PS multiply(int a, int b) { return PS(a * b); }
source share