Computer Science, asked by pinky137, 1 year ago

Define Constructor ????
With example............

Answers

Answered by kaurSneha
0
How construct a thing is known as constructor
Ex. The mason is constructor of our house

siddhartharao77: ^_^
kaurSneha: ☺.
Answered by siddhartharao77
2
A constructor is a special method that builds the instance of an object when a new object is created.

(or)

The constructor is called whenever a new object is created.

Constructor name will be same as the name of the class and they never have a return type.



Following is the example of the constructor: 

Class Demo
{

public : 
int a,b;

Demo()
{
a = 100;
b = 200;

}
};

int main()
{
Demo d;
cout << "a: "<< d.a << endl << "b: "<< d.b;
return 1;
}


Hope this helps!

siddhartharao77: Thank You Pinky For The Brainliest
pinky137: it's ok dude
Similar questions