1. Programming in C++ (3330702)
Amit S. Vaishnav
Lecturer in Computer Engineering
Government Polytechnic Gandhinagar
Diploma in Computer Engineering
Semester - III
3. Topics to be covered
3.1 Constructor Concept
3.2 Destructor
4. 3.1 Constructor Concept
Constructor :- A Constructor is a special
member function whose task is to initialize the
object of its class.
⮚ It is special because it name is same as the
class name.
⮚ The constructor is invoked whenever an
object of its associated class is created.
7. CHARACTERISTICS OF
CONSTRUCTORS
⮚ They should be declared in the public
section of the class declaration.
⮚ They are invoked automatically when the
object are created.
⮚ They cannot be virtual.
⮚ We cannot refer their addresses.
⮚ They cannot return values.
⮚ They can have default arguments.
8. 3.2 DESTRUCTOR
⮚ A destructor is used to destroy the object that
have created by a constructor.
⮚ The destructor is the member function whose
name is same as the class name but it is
preceded by a tilde(~).
⮚ A destructor never takes argument.
⮚ It never return any values.
11. CHARACTERISTICS OF
DESTRUCTORS
⮚ They are created to destroy objects that
have been created by a constructor.
⮚ They never take any arguments nor it
returns any value nor it has return type.
⮚ They are invoked automatically by the
compiler upon exit from program.
⮚ They should be declared in public section.
12. Conclusion :
⮚ A Constructor is a special member function
whose task is to initialize the object of its
class.
⮚ A destructor is used to destroy the object
that have created by a constructor and
preceded by a tilde(~).
13. Books and References :
• Object Oriented Programming with C++ -
Balagurusamy, E. McGrawHill, Delhi,
2012
• Object Oriented Programming in C++ -
Lafore, Robert SAMS, 2012
• https://www.includehelp.com/cpp-
programming-examples-solved-cpp-
programs.aspx
• https://vpmpce.wordpress.com/c-3330702/