Parameterised Constructor in C++

We know that whenever we create a class, a default constructor gets created, which is invisible mainly in other languages. But when we make a constructor by ourselves, there is flexibility for us to pass the arguments we might think are necessary for the constructor while creating the object in the primary function. Creating a parametrised constructor is pretty simple. We must make our constructor in the class function pass the necessary parameters.

C++ Code

Output:

/ tm p/ po Rl 42 Ph db .o
the value we have created for p1.b is: 10, the value we have created for p1.b is: p1.c = 15

C++ Code

Output:

/tmp/poRl42Phdb.o
the values for t1.x is:  20 the values for t2.x is:  15
After destructing the objects which have the value of x is as follows:  15
After destructing the objects which have the value of x is as follows:  20

C++ Code

Output:

after calculating the area of rectangle 1, we have got as 15624
after estimating the size of rectangle two, we have obtained: 28911