,object oriented programming c++ ,constructors ,objects ,property ,function ,default copy constructor ,deconstructor ,object as function parameter ,static data member ,friend class
object oriented programming c++
,object oriented programming c++ ,constructors ,objects ,property ,function ,default copy constructor ,deconstructor ,object as function parameter ,static data member ,friend class
object oriented programming c++
2. Name Muhammd Umair Sajjad
Roll No 531
Department BS(CS)(Evening)
Submitted to Mam Uswa Farooq
Submission date 16-06-2020
Govt. P/G Islamia College Faisalabad
3. 13.1 OBJECT ORIENTED PROGRAMMING
:- Object-Oriented programming (OOP) is a programming
technique or method in which we design a program by using objects
and classes.
OBJECTS
LIVING THINGS
HUMAN ANIMALS
NON LIVING
THINGS
EACH ITEM
INCLUDE
CAR,DESK,TABLE
etc.
4. :- An object is an entity that
consists of data and functions
:- c++ and java are the example of
object oriented language
5. FEATURES
•Objects:-
Object oriented programming is based on object. An object is
an entity that is shown in fig.
• Classes:-
Classes are designs for creating objects. In classes we see what
is private and what is public.
• Real-world Modeling:-
It is based in real-world modeling. Entities have different
properties and capabilities in real world.
6. FEATURES
• Reuseability:-
We make function one time and use many time.
• Information Hiding:-
We show only those data that we want to show
the user.
• Polymorphism:-
Ability of object behave in multiple way.
7. 13.2 OBJECTS
• Properties:-
Characteristics of an
object Example:-
Properties of a car is
• Color
• Price
• Model
• Engine Power
• Functions:-
It is the action
performed by an object
Example:-
Functions of a car is
• Start
• Stop
• Accelerate
• Reverse
8. 13.3 ClASSES
:- A group of object with same properties.
:- Use as a model to create same type object.
:- Use to define the characteristics and function of object.
Declaring:-
Keyword class is used to declare classs which specifies variables
and functions that are common to all objects of class.
Access Specifiers:-
A command use to specify access level of the class member
•
10. 13.4 CREATING OBJECTS
:- A class is prototype for creatin object
:- Process of creating an object of class called instantiation
Executing Member Function:-
• The member function can be
executed after creating an
object.
Defining Member Function
outside Class:-
• The declaration of member
function specified within class.
• If define function outside we
use resolution operator (::).
11. 13.5 CONSTRUCTORS
:- The member function has same name as class called
constructor.
Constructor cannot return any value
:- Use to initialize data member in the class.
Passing Parameters to Constructor:-
The parameters are written in parenthesis along with the
object name in declaration statement.
Constructor Overloading:-
When we declare multiple constructors with same name but
different parameters we called this constructor overloading.
12. 13.6 DEFAULT COPY CONSTRUCTOR
:- A constructor which is available by default in all classes.
:- We give parameters in parenthesis or using assignment
operator.
13. 13.7 DECONSTRUCTOR
:- A type of member function that is automatically executed
when an object of that class is destroyed is known as destructor.
:- Return no value
:- Cannot accept any parameter
:- Nmae is precede by sign (~)
14. 13.8 OBJECT AS FUNCTION PARAMETERS
:- We can be passed object as parameter to member function
Returning Objects from Member Function:-
The method of returning an object from member function
is same as returning a simple variable
15. 13.9 STATIC DATA MEMBER
:- A data member type that is shared among all objects of class
:- Define with static keyword
:- Characteristics of a static data member are same as normal
static variable
16. 13.10 FRIENDS FUNCTION
:- A function that allow to access the private and protected
members of a
particular class from outside the class.
:- Normally private and protected member of any cannot be
accessed from
outside the class.
:- It enable the function to access the private and protected
members of Both