Types of Constructor
There are fives types of the using of Constructor in C++
- Default Constructor
- Parametrized Constructor
- Copy Constructor
- Overloading Constructor
- Constructing two Dimensional Construtor
- Default Constructor :Below show of the program in the default constructor of the C++. Its has no parameter argument.
#include<iostream>
using namespace std;
class default1
{
public:
int a,b;
default1()// that called be default constructor
{
a=5;
b=8;
}
};
int main()
{ default1 x;
cout<<"a:"<<x.a<<endl<<"b:"<<x.b;
}
OUTPUT:
a:5
b:8
OUTPUT:
a:5
b:8
No comments:
Post a Comment