Tuesday 24 February 2015

Definition of Constructor in C++

Constructors
==============

A Constructor is a special member function for initialize a object.

Rules
=====

1) Constructor name should be same as classname
2) Constructor Should Not have any return type & should not return value.
3) Constructor shold also be overloaded
4) Constructor function Should not be called explicitly

Notes
=====
A Constructor is automatically called whenever creating object.

Destructor
==============
A Destructor is a special member function for deinitialize a object.

Rules
=====
1) Destructor name and Class Name should be same.
2) Destructor Should Not have any return type & should not return any value.
3) Destructor should not be overloaded.
4) Destructor Should not be called explicitly.
5) Destructor is differenciated from Constructor by tilde(~) Symbol.

Notes
=====
A Destructor Function is automatically called
whenever all duties of the object is over for erase a object from memory.

No comments:

Post a Comment