Default Constructor in Class in C++

Default constructor in C++ programming is a constructor which has no parameters. The default constructor will be called at the time of creating object of that class.

Class Program using Default Constructor

Program

#include<iostream.h>
#include<conio.h>
class cls //'cls' is name of Class.
{
public:
cls() //this is default constructor.
{
cout<<"This is Default Constructor"<<endl;
}
void fun() //this is function.
{
cout<<"This is Simple Function";
}
};
void main()
{    //'obj' is object of Class 'cls' and calling
 cls obj; //default constructor.
 obj.fun(); //calling 'fun()' function.
 getch();
}
Output
This is Default Constructor
This is Simple Function

Class Program Using Default Constructor and Destructor

Program

#include<iostream.h>
#include<conio.h>
class cls
{
public:
cls() //this is Constructor.
{
cout<<"Constructor Called"<<endl;
}
~cls() //this is Destructor.
{
cout<<"Destructor Called"<<endl;
getch();
}
};
void main()
{
cls obj; //'obj' is object of class 'cls'.
getch();
}
Output
Constructor Called
Destructor Called