30
OOPs in C++ Presented By: Ms. Niti Gupta

C plusplus

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: C plusplus

OOPs in C++

Presented By:

Ms. Niti Gupta

Page 2: C plusplus

Main Areas

Procedure Oriented Programming LanguageObject Oriented Programming LanguageConcepts of OOPs

Page 3: C plusplus

Procedural Oriented Programming Language

The main program coordinates calls to procedures and hands over appropriate data as parameters.

Page 4: C plusplus

Features of Procedure Oriented Programming Language

Emphasis is on doing things.Larger programs are divided in to smaller programs known as functions.Data is Global shared by almost all the functions.Employs Top Down approach in Program Design.

Page 5: C plusplus

Examples of Procedure Oriented Programming Language

COBOLFORTRANC

Page 6: C plusplus

Object-Oriented Concept

Objects of the program interact by sending messages to each other

Page 7: C plusplus

Features of OOPs

Emphasis is on data rather than procedures.Programs are divided into objects which are very close to the real world.Data is hidden and cannot be accessed by external functions.Functions that operate on the data are tied together into an object.Follows Bottom up approach in program design.

Page 8: C plusplus

Basic Concept of Object-Oriented

ObjectsClassesData AbstractionData EncapsulationInheritancePolymorphismDynamic Binding

Page 9: C plusplus

Objects

Run time entities that may represent a person, place, bank account or any item.Each object contains data, and code to manipulate the data.Data represents the attributes of that object and functions represents the behaviour of that object

Page 10: C plusplus

Objects Contd.

Page 11: C plusplus

Classes

User defined data types on which objects are created.Objects with similar properties and methods are grouped together to form a Class. For example, mango, apple and orange are members of class fruit.

Page 12: C plusplus

Data Abstraction

Abstraction refers to the act of representing essential features without including the background details or explanations.

Page 13: C plusplus

Data Encapsulation

Wrapping of data and functions into a single unit is known as data encapsulation.Data is not accessible to the outside world, only those functions which are wrapped in the class can access it.

Page 14: C plusplus

Inheritance

Process of deriving a new class from an existing one is called Inheritance.The existing class is known as base class, parent class or super class.The new class that is formed is called derived class, child class or sub class. Derived class has all the features of the base class plus it has some extra features also.

Page 15: C plusplus

Example of Inheritance

Automobile

Two Wheeler Three Wheeler Four Wheeler

Scooter Motor Bike Auto Rickshaw Car Bus

Page 16: C plusplus

Types of Inheritance

Single levelMulti levelMultipleHierarchicalHybrid

Page 17: C plusplus

Single Level Inheritance

Base Class

Derived Class

When there is one base class and only one class is deriving from it.

Page 18: C plusplus

Multi Level Level Inheritance

Class A

Class B

A class is derived from an already derived class. Class A is a base class for the derived class B. Class B is a base class for the derived class C. So, Class B is known as intermediate base class.

Class C

Page 19: C plusplus

Multiple Inheritance

Class A Class B

A Derived Class is created from two or more base classes.

Class C

Page 20: C plusplus

Hierarchical Inheritance

Class A

Class B Class C

Class D Class E

Two or more classes are derived from one base class.

Page 21: C plusplus

Hybrid Inheritance

Class A

Class B

Class C

Class D Class E

Combination of two or more types of Inheritance.

Page 22: C plusplus

Polymorphism

Ability to take more than one form.It includes

Function OverloadingOperator Overloading

Page 23: C plusplus

Function Overloading

Function Overloading refers to use of same function name for different purposes. These functions differ from each other by no. and types of arguments.

Draw()

Draw() Draw() Draw()

Page 24: C plusplus

Operator Overloading

Operator Overloading is a mechanism of redefining the meaning of C++ operators.For example: +, - ,++, -- ,* etc.

Page 25: C plusplus

Binding

Binding means connecting the function call to the code to be executed in response to the call.

Binding

Static Dynamic

Page 26: C plusplus

Static Binding

Static Binding means that the code associated with the function call is linked at compile time.Also known as early Binding or compile time Polymorphism.

Page 27: C plusplus

Dynamic Binding

Dynamic Binding means that the code associated with the function call is linked at run time. Also known as late Binding or run time polymorphism.

Page 28: C plusplus

Advantages of OOPs

Data Security.Reusability of existing code.Creating new data types.Abstraction.Less development time.Reduce Complexity.Better Productivity.

Page 29: C plusplus

Thanks

Page 30: C plusplus

Queries Please