Â
The Code given below can be used in TURBO C++ Compilers: -
#include <stdio.h>
#include<conio.h>
class Basic
{
public:
Basic()
{
cout << "Printed from constructor 1\n";
}
Basic(int n1)
{
cout << n1 << " printed from constructor 2\n";
}
Basic(int n2, float n3)
{
cout << n2 << " and " << n3 << " printed from constructor 3";
}
};
void main()
{
clrscr();
Basic b0;
Basic b1(5);
Basic b2(3, 6.9);
getch();
}
//...........Coded by Sahil Shaikh
The Code given below can be used in gcc/g++ Compilers: -
#include <iostream>
using namespace std;
class Basic
{
public:
Basic()
{
cout << "Printed from constructor 1\n";
}
Basic(int n1)
{
cout << n1 << " printed from constructor 2\n";
}
Basic(int n2, float n3)
{
cout << n2 << " and " << n3 << " printed from constructor 3";
}
};
int main()
{
Basic b0;
Basic b1(5);
Basic b2(3, 6.9);
return 0;
}
//...........Coded by Sahil Shaikh
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP