Thursday, July 22, 2010

What is C++ Constructor, and How to use Constructor with Inheritance

,
A constructor is a special type of function whose functionality is to intialize the data members of a class at a time of object creation.so that it is also called automatic intialization of objects.

Properties of a constructor:-
1.)It is invoked automatically at a time of the creation of object.so that the data members are intialized.

2.)It has neither return type nor void type.

3.)The name of a constructor and class should be identical.

4.)It should be declared on a public section.


Types of aconstructor:-

1.)Default Constructor.
2.)Copy Constructor.
3.)Parametrised constructor

0 comments to “What is C++ Constructor, and How to use Constructor with Inheritance”

Post a Comment