Search This Blog

Read Your Language

Types of Constructor

Types of Constructor

There are fives types of  the using of  Constructor in C++
  1. Default Constructor 
  2. Parametrized Constructor
  3. Copy Constructor 
  4.  Overloading Constructor 
  5. Constructing two Dimensional Construtor 

  1. 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

No comments:

Contact Form

Name

Email *

Message *

Followers