In this article, I have shown you the two types of constructors in C++ classes. The first one is the default constructor. It has no return value and no parameter. It has the same name as the class. It gets activated whenever an object of the class gets initiated with no parameters.
The second type of constructor is the parameterized constructor. It may have one or more parameters, but no return value. It has the same name as the class name. When object with the same number of parameters (in this example program it is 1), gets initialized in the program, it gets activated. Class and Object in C++
//Default and parameterized Constructors
# include <iostream.h>
# include <conio.h>
void test :: show_val()
cout <<“The value of variable is” << my_var <<endl;