OBJECT
PROGRAMING
WITH CPP
Topics of our presentation is :
1. Constructor
2.Friend function
3. Operator overloading
CONSTRUCTOR
 A constructor is a “special” member function whose task is
to initialize the objects of its class.
 It is special because its name is the same as class name.A
Constructor is invoked whenever an object of it’s associate
class is created.
 EXAMPLE :
 They should be declared in the public section.
 They do not have any return types, not even void .
 EXAMPLE :
FRIEND FUNCTION
 In C++ a FRIEND FUNCTION that is a
“friend” of a given class is allowed access to
private and protected data in that class.
 A function can be made a friend function using
keyword friend.
 Any friend function is preceded with friend keyword.
 The declaration of friend function should be made
inside body of the class starting with keyword friend.
 SYNTAX :
OPERATOR OVERLOADING
 This means C++ has the ability to provide the operators
with a special meaning for a data type, this ability is
known as operator overloading.
 Almost any operator can be overloaded in
c++.However there are few operator which
can not be overloaded and they follows:
 Operator overloading syntax :
THANK YOU

constructor , operator overloading ,friend function

  • 1.
    OBJECT PROGRAMING WITH CPP Topics ofour presentation is : 1. Constructor 2.Friend function 3. Operator overloading
  • 2.
    CONSTRUCTOR  A constructoris a “special” member function whose task is to initialize the objects of its class.  It is special because its name is the same as class name.A Constructor is invoked whenever an object of it’s associate class is created.  EXAMPLE :
  • 3.
     They shouldbe declared in the public section.  They do not have any return types, not even void .  EXAMPLE :
  • 4.
    FRIEND FUNCTION  InC++ a FRIEND FUNCTION that is a “friend” of a given class is allowed access to private and protected data in that class.  A function can be made a friend function using keyword friend.
  • 5.
     Any friendfunction is preceded with friend keyword.  The declaration of friend function should be made inside body of the class starting with keyword friend.  SYNTAX :
  • 6.
    OPERATOR OVERLOADING  Thismeans C++ has the ability to provide the operators with a special meaning for a data type, this ability is known as operator overloading.
  • 7.
     Almost anyoperator can be overloaded in c++.However there are few operator which can not be overloaded and they follows:
  • 8.
  • 9.