SlideShare a Scribd company logo
Object Oriented Programming Concepts
C
SharpC
ode.org
OOPS
Class – group of data members & member functions
Like person can be class having data members height and
weight and member functions as get_details() and
put_details() to manipulate on detailsput_details() to manipulate on details
Class is nothing until you create it’s object
Object – instantiates class allocates memory
C
SharpC
ode.org
OOPS Fundamentals…
Access to data members & member functions can be done
using object only (if they are not static!)
OOPS features are
1. Encapsulation1. Encapsulation
2. Data hiding
3. Data reusability
4. Overloading (polymorphism)
5. Overriding
C
SharpC
ode.org
OOPS Features…
Encapsulation – making one group of data members &
member functions
Can be done through class
Then group of data members & Member functions will beThen group of data members & Member functions will be
available just by creating object.
C
SharpC
ode.org
OOPS Features…
Data Hiding – can be done through access modifiers
Access modifiers are private, public, protected and internal
Private members or member function won’t be available
outside classoutside class
Public – available all over in program outside class also
C
SharpC
ode.org
OOPS Features…
Protected – members that are available in class as well as in
it’s child class
Private for another class
Protected access modifier comes only when inheritance isProtected access modifier comes only when inheritance is
in picture
Internal is used with assembly creation
C
SharpC
ode.org
class employee //Class Declaration
{
private:
char empname[50];
int empno;
public:
void getvalue() {
cout<<"INPUT Employee Name:";
cin>>empname;
cout<<"INPUT Employee Number:";
cin>>empno; }
void displayvalue() {void displayvalue() {
cout<<"Employee Name:"<<empname<<endl;
cout<<"Employee Number:"<<empno<<endl; }
};
main()
{
employee e1; //Creation of Object
e1.getvalue();
e1.displayvalue();
}
C
SharpC
ode.org
OOPS Features…
Overloading – taking different output of one method or
operator based on parameters and return types
Like add() method performs addition and add(int a,int b)
performs addition of ‘a’ and ‘b’ passed when callingperforms addition of ‘a’ and ‘b’ passed when calling
Also, + operator performs addition of two numbers as well
as concatenation of strings
C
SharpC
ode.org
class arith
{
public:
void calc(int num1)
{
cout<<"Square of a given number: " <<num1*num1 <<endl;
}
void calc(int num1, int num2 )
{
cout<<"Product of two whole numbers: " <<num1*num2 <<endl;
}
};};
int main() //begin of main function
{
arith a;
a.calc(5);
a.calc(6,7);
}
This is example of method overloading, output will be
Square of given number : 25
Product of two whole numbers : 42
C
SharpC
ode.org
OOPS Features…
Data Reusability – helps in saving developers time
You can use already created class to crate new one
Called inheritance
Already existing class is base class and new created isAlready existing class is base class and new created is
derived class
Base class members can be available in derived class and to
access them create object of derived class
Like from parent to child
C
SharpC
ode.org
class CPolygon {
protected:
int width, height;
public:
void set_values (int a, int b)
{ width=a; height=b;}
};
class CRectangle: public CPolygon {
public: int area ()
{ return (width * height); }
};
class CTriangle: public CPolygon {class CTriangle: public CPolygon {
public: int area ()
{ return (width * height / 2); } };
int main () {
CRectangle rect;
CTriangle trgl; rect.set_values (4,5);
trgl.set_values (4,5);
cout << rect.area() << endl;
cout << trgl.area() << endl;
return 0;
}
C
SharpC
ode.org
OOPS Features…
In C++, overriding is a concept used in inheritance which involves a base class
implementation of a method.
Then in a subclass, you would make another implementation of the method. This is
overriding. Here is a simple example.
class Base
{{
public:
virtual void DoSomething() {x = x + 5;}
private:
int x;
};
class Derived : public Base
{
public:
virtual void DoSomething() { y = y + 5; Base::DoSomething(); }
private:
int y;
};
C
SharpC
ode.org

More Related Content

What's hot (20)

PDF
C++ [ principles of object oriented programming ]
Rome468
 
PPTX
concept of oops
prince sharma
 
PDF
Object oriented concepts
Pranali Chaudhari
 
PPTX
Oops concepts
Kanan Gandhi
 
PPTX
Object-oriented programming
Neelesh Shukla
 
PPTX
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
PPTX
Oops concept in c++ unit 3 -topic 4
MOHIT TOMAR
 
PPT
Object Oriented Programming Concepts using Java
Glenn Guden
 
PPTX
Object Oriented Programming Concepts
Abhigyan Singh Yadav
 
PPT
Lecture 2
emailharmeet
 
PPT
Oops And C++ Fundamentals
Subhasis Nayak
 
PPT
C++ classes
imhammadali
 
PPT
Object Oriented Concepts and Principles
deonpmeyer
 
PPTX
Oop c++class(final).ppt
Alok Kumar
 
DOC
Course outline [csc241 object oriented programming]
Asfand Hassan
 
PPTX
Introduction to oop
colleges
 
PPT
Oops ppt
abhayjuneja
 
PPT
Object Oriented Language
dheva B
 
PPTX
the Concept of Object-Oriented Programming
Aida Ramlan II
 
C++ [ principles of object oriented programming ]
Rome468
 
concept of oops
prince sharma
 
Object oriented concepts
Pranali Chaudhari
 
Oops concepts
Kanan Gandhi
 
Object-oriented programming
Neelesh Shukla
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
Oops concept in c++ unit 3 -topic 4
MOHIT TOMAR
 
Object Oriented Programming Concepts using Java
Glenn Guden
 
Object Oriented Programming Concepts
Abhigyan Singh Yadav
 
Lecture 2
emailharmeet
 
Oops And C++ Fundamentals
Subhasis Nayak
 
C++ classes
imhammadali
 
Object Oriented Concepts and Principles
deonpmeyer
 
Oop c++class(final).ppt
Alok Kumar
 
Course outline [csc241 object oriented programming]
Asfand Hassan
 
Introduction to oop
colleges
 
Oops ppt
abhayjuneja
 
Object Oriented Language
dheva B
 
the Concept of Object-Oriented Programming
Aida Ramlan II
 

Viewers also liked (20)

PPT
Oops and c fundamentals
umesh patil
 
KEY
Project object explain your choice
Soren
 
PPT
.net training | learn .net | Microsoft dot net Course | Microsoft dot net onl...
Nancy Thomas
 
DOCX
Inline function(oops)
Jay Patel
 
PPTX
object oriented programing lecture 1
Geophery sanga
 
PPTX
OOP - Benefits and advantages of OOP
Mudasir Qazi
 
PDF
OOP Chapter 8 : Inheritance
Atit Patumvan
 
PPTX
Objective c slide I
Diksha Bhargava
 
PDF
OOP with C#
Manuel Scapolan
 
PPTX
iOS Developer Interview Questions
Clark Davidson
 
PDF
Object-oriented Programming-with C#
Doncho Minkov
 
PPT
Concepts of Asp.Net
vidyamittal
 
PDF
LIDO勉強会#1
Masaharu Hayashi
 
PPTX
describing objects
Rushikesh Raut
 
PPTX
A P J Abdul Kalam
Naveen Sihag
 
PDF
Asp .net web form fundamentals
Gopal Ji Singh
 
PDF
tybsc it asp.net full unit 1,2,3,4,5,6 notes
WE-IT TUTORIALS
 
PPTX
Introduction to asp.net
Melick Baranasooriya
 
PPT
C#/.NET Little Wonders
BlackRabbitCoder
 
Oops and c fundamentals
umesh patil
 
Project object explain your choice
Soren
 
.net training | learn .net | Microsoft dot net Course | Microsoft dot net onl...
Nancy Thomas
 
Inline function(oops)
Jay Patel
 
object oriented programing lecture 1
Geophery sanga
 
OOP - Benefits and advantages of OOP
Mudasir Qazi
 
OOP Chapter 8 : Inheritance
Atit Patumvan
 
Objective c slide I
Diksha Bhargava
 
OOP with C#
Manuel Scapolan
 
iOS Developer Interview Questions
Clark Davidson
 
Object-oriented Programming-with C#
Doncho Minkov
 
Concepts of Asp.Net
vidyamittal
 
LIDO勉強会#1
Masaharu Hayashi
 
describing objects
Rushikesh Raut
 
A P J Abdul Kalam
Naveen Sihag
 
Asp .net web form fundamentals
Gopal Ji Singh
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
WE-IT TUTORIALS
 
Introduction to asp.net
Melick Baranasooriya
 
C#/.NET Little Wonders
BlackRabbitCoder
 
Ad

Similar to Object Oriented Programming Concepts (20)

PPTX
Oop concept in c++ by MUhammed Thanveer Melayi
Muhammed Thanveer M
 
PPTX
OOPS Basics With Example
Thooyavan Venkatachalam
 
PDF
C++ OOPS Concept
Boopathi K
 
PPTX
Four Pillers Of OOPS
Shwetark Deshpande
 
DOC
Questpond - Top 10 Interview Questions and Answers on OOPS
gdrealspace
 
PPTX
OOP_in_CPP_Animesh_Animated_Diagram.pptx
animesh713331
 
DOC
Introduction to OOPs Concept- Features, Basic concepts, Benefits and Applicat...
KrishnaveniT8
 
PPTX
Basic Concepts Of OOPS/OOPS in Java,C++
Guneesh Basundhra
 
PPTX
contains explanation of oops concepts in c++
jayasmruthicmscse
 
PPTX
ECAP444 - OBJECT ORIENTED PROGRAMMING USING C++.pptx
vmickey4522
 
PPTX
Rajib Ali Presentation on object oreitation oop.pptx
domefe4146
 
PPT
2. oop with c++ get 410 day 2
Mukul kumar Neal
 
PPTX
Object oriented programming
Saiful Islam Sany
 
ODP
Ayush oops
Ayush Pandey
 
PPTX
Principles of oop
SeethaDinesh
 
PPTX
Object oriented programming
MH Abid
 
PPTX
Characteristics of oop
Rasim Izhar Ali
 
Oop concept in c++ by MUhammed Thanveer Melayi
Muhammed Thanveer M
 
OOPS Basics With Example
Thooyavan Venkatachalam
 
C++ OOPS Concept
Boopathi K
 
Four Pillers Of OOPS
Shwetark Deshpande
 
Questpond - Top 10 Interview Questions and Answers on OOPS
gdrealspace
 
OOP_in_CPP_Animesh_Animated_Diagram.pptx
animesh713331
 
Introduction to OOPs Concept- Features, Basic concepts, Benefits and Applicat...
KrishnaveniT8
 
Basic Concepts Of OOPS/OOPS in Java,C++
Guneesh Basundhra
 
contains explanation of oops concepts in c++
jayasmruthicmscse
 
ECAP444 - OBJECT ORIENTED PROGRAMMING USING C++.pptx
vmickey4522
 
Rajib Ali Presentation on object oreitation oop.pptx
domefe4146
 
2. oop with c++ get 410 day 2
Mukul kumar Neal
 
Object oriented programming
Saiful Islam Sany
 
Ayush oops
Ayush Pandey
 
Principles of oop
SeethaDinesh
 
Object oriented programming
MH Abid
 
Characteristics of oop
Rasim Izhar Ali
 
Ad

Recently uploaded (20)

PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PDF
Council of Chalcedon Re-Examined
Smiling Lungs
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PPTX
Difference between write and update in odoo 18
Celine George
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PPTX
infertility, types,causes, impact, and management
Ritu480198
 
PDF
Introduction presentation of the patentbutler tool
MIPLM
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
PDF
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
PDF
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
Council of Chalcedon Re-Examined
Smiling Lungs
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Controller Request and Response in Odoo18
Celine George
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
Difference between write and update in odoo 18
Celine George
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
infertility, types,causes, impact, and management
Ritu480198
 
Introduction presentation of the patentbutler tool
MIPLM
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 

Object Oriented Programming Concepts

  • 1. Object Oriented Programming Concepts C SharpC ode.org
  • 2. OOPS Class – group of data members & member functions Like person can be class having data members height and weight and member functions as get_details() and put_details() to manipulate on detailsput_details() to manipulate on details Class is nothing until you create it’s object Object – instantiates class allocates memory C SharpC ode.org
  • 3. OOPS Fundamentals… Access to data members & member functions can be done using object only (if they are not static!) OOPS features are 1. Encapsulation1. Encapsulation 2. Data hiding 3. Data reusability 4. Overloading (polymorphism) 5. Overriding C SharpC ode.org
  • 4. OOPS Features… Encapsulation – making one group of data members & member functions Can be done through class Then group of data members & Member functions will beThen group of data members & Member functions will be available just by creating object. C SharpC ode.org
  • 5. OOPS Features… Data Hiding – can be done through access modifiers Access modifiers are private, public, protected and internal Private members or member function won’t be available outside classoutside class Public – available all over in program outside class also C SharpC ode.org
  • 6. OOPS Features… Protected – members that are available in class as well as in it’s child class Private for another class Protected access modifier comes only when inheritance isProtected access modifier comes only when inheritance is in picture Internal is used with assembly creation C SharpC ode.org
  • 7. class employee //Class Declaration { private: char empname[50]; int empno; public: void getvalue() { cout<<"INPUT Employee Name:"; cin>>empname; cout<<"INPUT Employee Number:"; cin>>empno; } void displayvalue() {void displayvalue() { cout<<"Employee Name:"<<empname<<endl; cout<<"Employee Number:"<<empno<<endl; } }; main() { employee e1; //Creation of Object e1.getvalue(); e1.displayvalue(); } C SharpC ode.org
  • 8. OOPS Features… Overloading – taking different output of one method or operator based on parameters and return types Like add() method performs addition and add(int a,int b) performs addition of ‘a’ and ‘b’ passed when callingperforms addition of ‘a’ and ‘b’ passed when calling Also, + operator performs addition of two numbers as well as concatenation of strings C SharpC ode.org
  • 9. class arith { public: void calc(int num1) { cout<<"Square of a given number: " <<num1*num1 <<endl; } void calc(int num1, int num2 ) { cout<<"Product of two whole numbers: " <<num1*num2 <<endl; } };}; int main() //begin of main function { arith a; a.calc(5); a.calc(6,7); } This is example of method overloading, output will be Square of given number : 25 Product of two whole numbers : 42 C SharpC ode.org
  • 10. OOPS Features… Data Reusability – helps in saving developers time You can use already created class to crate new one Called inheritance Already existing class is base class and new created isAlready existing class is base class and new created is derived class Base class members can be available in derived class and to access them create object of derived class Like from parent to child C SharpC ode.org
  • 11. class CPolygon { protected: int width, height; public: void set_values (int a, int b) { width=a; height=b;} }; class CRectangle: public CPolygon { public: int area () { return (width * height); } }; class CTriangle: public CPolygon {class CTriangle: public CPolygon { public: int area () { return (width * height / 2); } }; int main () { CRectangle rect; CTriangle trgl; rect.set_values (4,5); trgl.set_values (4,5); cout << rect.area() << endl; cout << trgl.area() << endl; return 0; } C SharpC ode.org
  • 12. OOPS Features… In C++, overriding is a concept used in inheritance which involves a base class implementation of a method. Then in a subclass, you would make another implementation of the method. This is overriding. Here is a simple example. class Base {{ public: virtual void DoSomething() {x = x + 5;} private: int x; }; class Derived : public Base { public: virtual void DoSomething() { y = y + 5; Base::DoSomething(); } private: int y; }; C SharpC ode.org