..

FreePrograms


C programming Tutorial 

Free C Programs, C Programs Download


Embedded C lang & 8051(Embedded Products)


  CONTACT US   ABOUT US   PRIVACY  DISCLAIMER

FREE C PROGRAMS 

 C Tutorial for beginners
What is C C vs C++ vs Java Program Structure Data Types in C Basic Rules of C & C++
Functions in C If, Else Conditions Loops in C Switch Case Arrays
Pointers Structures in C Strings in C Command Line Arguments Type Casting
Linked Lists Recursion Binary Trees Inheritance Multiple Inheritance
Templates File I/O Object Oriented Programming  Data Structures in C C interview Questions

/*Constructors and Destructors in CPP    C++/CPP Tutorial.*/


 

Constructors are called every time you create an object, and destructors are called every time you destroy an object.

•Constructors and destructors do not have return types nor can they return values.
•References and pointers cannot be used on constructors and destructors because their addresses cannot be taken.
•Constructors cannot be declared with the keyword virtual.
•Constructors and destructors cannot be declared static, const, or volatile.
•Unions cannot contain class objects that have constructors or destructors.

Constructor Example
Employee::Employee() {
points = 10;
work = 10;
health = 10;
}
 

Destructor Example
The name of the destructor is the name of the class, preceded by a tilde (~). Here's an example of a destructor:

Employee::~Employee() {
points = 0;
work = 0;
health = 0;
}

 

COPYRIGHT 2009 ALL RIGHTS RESERVED FREECPROGRAMS.COM