OOP
• It is a high level programming language
• It is based on objects and deals with object manipulation.e,g
Java,C++
• Oop is Categorized In 4th Generation language and non-
structured
Object
It is an instant of class that defines the real entity in detail.
OR
It is a layout(pattern) that reflects (defines) the original entity in detail.
Note:- An object have the same relationship with the class as that of variable may
have with primitive data type.
Entity
It is the name property of a Object/Event/Person. There are two type of entity.
• Physical
• Logical
Physical Entity
These entities are tangible in nature. e,g. (a)Person (b)Place (c)object
Logical Entity
These entities are intangible in nature. e,g. Event
Object Manipulation
If various operations/functions/methods are applied on objects, that is named
as object manipulation.
C++ Data Types
Basic/ Default / Primitive data types (Used in structural
programming )
User Defined data types (Used in OOP)
Basic/ Default / Primitive Data Types
These are the data types that are available by default to every
user and he/she can use it by following standard rules
User Defined Data Types
These are the data types that deal with the real time objects.
Example : Classes , Structures
Primitive Data Varibles Class Object
Types
Int, float x, y User Defined L1
Char etc.. a,b,c Data Type Vc
etc.. e,g : Library S1 etc..
gcuf etc..
CLASS
It is a template (Layout, blue print) that generates numberless real time
objects.
Class interface/class specification+ class interface/class definition
Technical Definition
Class=Variable (Objects) +Object manipulation
OR
Class=Variable (Objects) +procedures/methods/functions
Data Items Or Data Members
Components or constituents of class
OR
These are the data members (Variables) of the class, that
defines the properties/characteristics of the class declared.
These are considered as private however not necessary condition.
Note : By default the status of data items is private in the class.
Member Functions
These are the methods/procedures/operations that are applied
on the data (i,e data items) for obtaining the desired
results/objectives.
Note : In general the status of data items is public in the class
however not necessary condition.
Note : If we never write any thing inside the class every thing will
be private.
Inline Function:
The functions that are defied inside the class interface are
called inline functions.
Data_item(n);
public:
member_function(1);
member_function(n);
};
Access Specifier
These are the keywords/reserved words ,acts as indicator for
the compiler (included by the programmer inside the class interface)
according to which the properties of data items as well as member
function are defined.
(OR)
These are the Keywords that provide the accessibility for the
user/programmer being included inside the class interface.
Syntax
public:--------(1)
private:-------(2)
protected:----(3)
Private
Protected
Public
It is such a specifier,if it is included in a class interface every
element written afterwards should contain following features:
//for input from the user
void get_data(int x,float a, char s)
{
roll_no=x;
age=a;
sex=s;
}
Features of class
• User defines data type.
• Declaration: The Keyword of ‘class’ is used for
declaration.
• Members : It might contain of data items or member
functions or both
• Default Status: By default data items are private:
Use Of Class
It is used in Real time for solving any real world problem
Destructor:-
These are the special member functions that are used to de
allocate already memory allocated to various objects
Properties/principle/features/constituents
o Destructors should have same name as that of class name
similar to the constructor
o Destructors have no return type not even “void”.
o These cannot be overloaded
o It should be declared public necessarily
o These functions cannot be called explicitly by the
programmer
o It will be called automaticall.
o
Memory Concept In Classes
There are mainly two types of memory in class
• Static memory
• Dynamic memory
•
Static memory(static binding, compile binding, early
binding)
If the memory allocation is finalize at the compile time of a
program ,it is called static binding.
Class A
Single
Inheritance
Class B
Conditions:
o No. of base classes should be one every time
o As well as no derived classes=1
Multiple Inheritance
In this type of Inheritance some or all of the futures of two or
more than two classes are being transferred towards any no. of
newly designed classes.
Conditions
o No. of base classes =>2
o No. of derived classes = any no.
Multi-level Inheritance
It is such type of Inheritance in which all of the futures are
transferred from an already derived class towards newly designed
class
Class A
Class B
Class D
Conditions
o At least one class should be available that is already derived
class and from that class we drive some classes
Modes Of Inheritance
• Public
• Private
• Protected
Modes Class interface Derived Outside the
(Inside the class
class)
Public
Private
Protected
General Syntax Of Inheritance:
Class derived_class_name: Mode Of Inheritance (space)
base_class_name
Example:
Class circle: public shape
Class bsse: protected bcs
Friend functions
If we want to utilize the private data items and private
member functions out side the class (i.e main of the program) we
get help of friend functions
Syntax : friend(keyword) retur_type name(arguments)
COMPOSITION:
It is an important future of oop languages, that provides the
affect of software reusability ; here we obtain the features of
base/already designed calss be declaring/passing the objects o it in
the new clas.
Objective/target: Software reusability
Software (program as whole (OR) some part of it)
POLYMORPHISM:
Poly two or more than two & Morphism form/shape
It is an Important feature/property/characteristic of oop
language with the help of which a single entity behaves differently
• Function(s)
• Function Overloading
• Function Overriding
Implementation of Polymorphism
It can be implemented with the help of function overriding
concept as well as virtual functions.
Overrided Functions
Conditions For Function Overriding:
• Two or more than two function with the same name
• Function should be resided in different classes
Note: In function overriding our focus is on the definition of the
function that we want to override (i.e the functionality should be
different)
Virtual functions:
If any function decelerator signature is attached with the
keyword of “Virtual” it will have the characteristics of Virtual
function.
Pure Virtual functions:
If any virtual function is assigned the zero value at the time of
its declaration it is called pure virtual function.
i.e. virtual void show()=o;
Abstract Class:
If any class (interface) contains at least one pure virtual
function that is know as abstract class
Properties:-
o User/programmer is not allowed to design/create he object of
that class;
Concrete Class
Any class derived/inherited form an abstract class is know as
concrete class.
Note. User can create objects within the concrete class