Constructor and destructor functions
Constructor
Constructor is a special type member function,which execute automatically whenever an object is created.
Rules of creating Constructor:
*Name :Constructor name is same as class name.
*Scope :Public
*Return Type :Nil
*Argument :Optional
*Overloading :Possible
Use:
*Variable Initialization
*Resource Allocation
*Type Conversion
Destructor
Destructor is a special type member function,which execute automatically whenever an object is destroyed.
Rules for creating Destructor:
*Name :Destructor name is same as class name with prefix a tilled(~) character
*Scope :public
*Return Type :Nil
*Argument :Not Possible
*Overloading :Not Possible
Use
*Resource (Memory) Deallocation.
*Cleanup process
|
|
|
