C++ Program to using the default constructor

In this program, You will learn how to implement the default constructor in C++.

Default constructor in C++

Test() { 

Example: How to implement default constructor in C++.

using namespace std;

class Test {
   int a;

   Test() {
       cout << "Enter a number:";
       cin >> a;

   void display() {
       cout << "Value of a is:" << a;

int main() {

   Test obj;

   return 0;


Enter a number:120
Value of a is:120