PRESENTED BY
Ms.V.VENNILA., MCA.,M.Phil.,
Asst.Prof of InformationTechnology,
Bon Secours College forWomen,
Thanjavur
 A Constructor is a member function of class
which initializes the objects of the class .
 It is automatically called ,when the objects is
created.
 Constructor have different from normal
functions.
 It same as class name itself.
 It don’t have a return type.
 Its automatically called , when the objects is
created.
 class name::function name
 default constructor
 parameterized constructor
 copy constructor
It is the constructor which doesn’t
take any arguments.
It has no parameters.
class name()
{
………
}
There are the constructor with parameters.
Using this constructor , we can provide different
values to data of different objects by passing the
value as arguments.
class cube()
{
public:
int side;
cube(int x)
{
side=x;
}
};
 There are the special type of constructor
which takes on object as arguments and is
used to copy values of data members of one
objects into other objects.
A Destructor is a special member function that
works opposite to constructor.
Destructor are used to destroy or delete the objects.
class name()
{
……….
}
The destructor name should exactly mach with the
class name.
A Destructor is declared to begin with (~) –tilde
symbol.
A Destructor is automatically called when the
program execution is finished.
THANK YOU ALL

constructor and destructor

  • 1.
    PRESENTED BY Ms.V.VENNILA., MCA.,M.Phil., Asst.Profof InformationTechnology, Bon Secours College forWomen, Thanjavur
  • 2.
     A Constructoris a member function of class which initializes the objects of the class .  It is automatically called ,when the objects is created.  Constructor have different from normal functions.  It same as class name itself.  It don’t have a return type.  Its automatically called , when the objects is created.  class name::function name
  • 3.
     default constructor parameterized constructor  copy constructor
  • 4.
    It is theconstructor which doesn’t take any arguments. It has no parameters. class name() { ……… }
  • 5.
    There are theconstructor with parameters. Using this constructor , we can provide different values to data of different objects by passing the value as arguments. class cube() { public: int side; cube(int x) { side=x; } };
  • 6.
     There arethe special type of constructor which takes on object as arguments and is used to copy values of data members of one objects into other objects.
  • 7.
    A Destructor isa special member function that works opposite to constructor. Destructor are used to destroy or delete the objects. class name() { ………. } The destructor name should exactly mach with the class name. A Destructor is declared to begin with (~) –tilde symbol. A Destructor is automatically called when the program execution is finished.
  • 8.