What do you understand by constructor in C++?

What do you understand by constructor in C++?

What is constructor?
Basically, constructor is the special type of function in class which can automatically called at the time of object creation.
or,
constructor is the function which will called when we create any new object.

Constructor property:
-Class name and constructor name should be same.
-There is no return type of constructor like void,int etc.
Syntax-
//make class
class r4r
{
//constructor
r4r()
{
body;
}
};

Type of constructor:
1.Default constructor
2.Parametrized constructor
3.Copy constructor

1.Default constructor:
-Default constructor are those function in which we cannot pass any argument.

2.Parameterized constructor:
-This constructor are those in which we can pass an argument.

3.Copy constructor:
-This is the constructor when we copy one object to another.




Read More →
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!