C++ Program to display the cube of the number upto a given integer using constructor overloading

Write C++ Program to display the cube of the number upto a given integer using constructor overloading.

C++ Program to display the cube of the number upto a given integer

The concept of using more than one constructor with the same name is called constructor overloading.

In this program, the constructor must obey one or both of the following rules.

  1. All constructors with the same name and having a different number of parameters.
    • T4Tutorials() and another constructor as T4Tutorials(int p, int q).
  2. All constructors with the same name and have the same number of parameters but of different data types.
    • T4Tutorials(int p, int q) and another constructor as T4Tutorials(double p, double q).

Note: In this example, we are overloading the constructor with the following rule;

One constructor as T4Tutorials() and another constructor as T4Tutorials(int p, int q).

Output

Please enter the number:

3

cube of 1 is: 1

cube of 2 is: 8

cube of 3 is: 27