Calling a constructor in C++ || Constructor || C++
In this, we are going to see how to call a Constructor, in C++. 
 


The Code given below can be used in TURBO C++ Compilers: -

#include <iostream.h>
#include<conio.h>

class construct
{
public:
    construct()
    {
        cout << "Congrats, You have successfully called a constructor";
        //cout <<"I'm constructor, At your service."
    }
};

void main()
{
    clrscr();
    construct p;
    getch();
}

//..........Coded by YASH ALAPURIA

The Code given below can be used in gcc/g++ Compilers: -

#include <iostream>
#include <stdlib.h>
using namespace std;

class construct
{
public:
    construct()
    {
        cout << "Congrats, You have successfully called a constructor";
        //cout <<"I'm constructor, At your service."
    }
};

int main()
{
    system("cls");
    construct p;
    return 0;
}

//..........Coded by YASH ALAPURIA


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post