40. Abstract Operation

 Your task is to declare a pure virtual function inside the class Operation.

  • This function will be implemented by derived classes SquareOp and CubeOp.
     
  • The program will read a number and the operation type ("square" or "cube"), create the correct object, and print the result using the base pointer.

     

Example
 Input:

5 square

Output:

25

 

Input:

3 cube

Output:

27
Loading...

Input

5 square

Expected Output

25