You are given a base class Operation that represents a mathematical operation.
Your task is to declare a pure virtual function inside the Operation class so that it becomes an abstract base class.
Two derived classes already exist:
SquareOp → calculates the square of a numberCubeOp → calculates the cube of a numberThe program will:
"square" or "cube")This problem focuses on runtime polymorphism and abstract interfaces, which are commonly used in embedded and firmware systems.
Input Specification
nopName"square" or "cube"Input is provided in a single line, separated by space.
Output Specification
n.No extra spaces or newline characters are required.
Example 1
Input
5 square
Output
25
Example 2
Input
3 cube Output
27Constraints
n is a valid 32-bit signed integerint arithmetic
Input
5 square
Expected Output
25