#include <iostream>
using namespace std;
class Number {
private:
int num;
public:
void getNumber(void)
{
cout << "Enter an integer number: ";
cin >> num;
}
int returnNumber(void)
{
return num;
}
};
class Square : public Number {
public:
int getSquare(void)
{
int num, sqr;
num = returnNumber();
sqr = num * num;
return sqr;
}
};
class Cube : public Number {
private:
public:
int getCube(void)
{
int num, cube;
num = returnNumber();
cube = num * num * num;
return cube;
}
};
int main()
{
Square objS;
Cube objC;
int sqr, cube;
objS.getNumber();
sqr = objS.getSquare();
cout << "Square of " << objS.returnNumber() << " is: " << sqr << endl;
objC.getNumber();
cube = objC.getCube();
cout << "Cube of " << objS.returnNumber() << " is: " << cube << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgTnVtYmVyIHsKcHJpdmF0ZToKICAgIGludCBudW07CgpwdWJsaWM6CiAgICB2b2lkIGdldE51bWJlcih2b2lkKQogICAgewogICAgICAgIGNvdXQgPDwgIkVudGVyIGFuIGludGVnZXIgbnVtYmVyOiAiOwogICAgICAgIGNpbiA+PiBudW07CiAgICB9CgogICAgaW50IHJldHVybk51bWJlcih2b2lkKQogICAgewogICAgICAgIHJldHVybiBudW07CiAgICB9Cn07CgpjbGFzcyBTcXVhcmUgOiBwdWJsaWMgTnVtYmVyIHsKcHVibGljOgogICAgaW50IGdldFNxdWFyZSh2b2lkKQogICAgewogICAgICAgIGludCBudW0sIHNxcjsKICAgICAgICBudW0gPSByZXR1cm5OdW1iZXIoKTsKICAgICAgICBzcXIgPSBudW0gKiBudW07CiAgICAgICAgcmV0dXJuIHNxcjsKICAgIH0KfTsKCmNsYXNzIEN1YmUgOiBwdWJsaWMgTnVtYmVyIHsKcHJpdmF0ZToKcHVibGljOgogICAgaW50IGdldEN1YmUodm9pZCkKICAgIHsKICAgICAgICBpbnQgbnVtLCBjdWJlOwogICAgICAgIG51bSA9IHJldHVybk51bWJlcigpOwogICAgICAgIGN1YmUgPSBudW0gKiBudW0gKiBudW07CiAgICAgICAgcmV0dXJuIGN1YmU7CiAgICB9Cn07CgppbnQgbWFpbigpCnsKICAgIFNxdWFyZSBvYmpTOwogICAgQ3ViZSBvYmpDOwogICAgaW50IHNxciwgY3ViZTsKCiAgICBvYmpTLmdldE51bWJlcigpOwogICAgc3FyID0gb2JqUy5nZXRTcXVhcmUoKTsKICAgIGNvdXQgPDwgIlNxdWFyZSBvZiAiIDw8IG9ialMucmV0dXJuTnVtYmVyKCkgPDwgIiBpczogIiA8PCBzcXIgPDwgZW5kbDsKCiAgICBvYmpDLmdldE51bWJlcigpOwogICAgY3ViZSA9IG9iakMuZ2V0Q3ViZSgpOwogICAgY291dCA8PCAiQ3ViZSAgIG9mICIgPDwgb2JqUy5yZXR1cm5OdW1iZXIoKSA8PCAiIGlzOiAiIDw8IGN1YmUgPDwgZW5kbDsKCiAgICByZXR1cm4gMDsKfQo=