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
Object oriented programming. (1).pptx
baadshahyash
 
PPTX
Presentation 1st
Connex
 
PPTX
ECAP444 - OBJECT ORIENTED PROGRAMMING USING C++.pptx
vmickey4522
 
PPT
Unit 5.ppt
JITTAYASHWANTHREDDY
 
PPTX
Unit - I Fundamentals of Object Oriented Programming .pptx
tanmaynanaware20
 
PDF
@vtucode.in-module-1-c++-2022-scheme.pdf
TheertheshTheertha1
 
PPT
The smartpath information systems c plus plus
The Smartpath Information Systems,Bhilai,Durg,Chhattisgarh.
 
PPTX
Opp concept in c++
SadiqullahGhani1
 
PPT
Data structure and problem solving ch01.ppt
Ping261512
 
PPTX
03 object-classes-pbl-4-slots
mha4
 
PPTX
03 object-classes-pbl-4-slots
mha4
 
PPTX
C++ppt. Classs and object, class and object
secondakay
 
PPTX
Lecture-10_PHP-OOP.pptx
ShaownRoy1
 
DOCX
I assignmnt(oops)
Jay Patel
 
PPTX
C++ & Data Structure - Unit - first.pptx
KONGUNADU COLLEGE OF ENGINEERING AND TECHNOLOGY
 
PPTX
C++ programming introduction
sandeep54552
 
PPTX
OBJECT ORIENTED PROGRAMING IN C++
Dev Chauhan
 
PPTX
oop lecture 3
Atif Khan
 
PPTX
concepts of object and classes in OOPS.pptx
urvashipundir04
 
Object oriented programming. (1).pptx
baadshahyash
 
Presentation 1st
Connex
 
ECAP444 - OBJECT ORIENTED PROGRAMMING USING C++.pptx
vmickey4522
 
Unit - I Fundamentals of Object Oriented Programming .pptx
tanmaynanaware20
 
@vtucode.in-module-1-c++-2022-scheme.pdf
TheertheshTheertha1
 
The smartpath information systems c plus plus
The Smartpath Information Systems,Bhilai,Durg,Chhattisgarh.
 
Opp concept in c++
SadiqullahGhani1
 
Data structure and problem solving ch01.ppt
Ping261512
 
03 object-classes-pbl-4-slots
mha4
 
03 object-classes-pbl-4-slots
mha4
 
C++ppt. Classs and object, class and object
secondakay
 
Lecture-10_PHP-OOP.pptx
ShaownRoy1
 
I assignmnt(oops)
Jay Patel
 
C++ & Data Structure - Unit - first.pptx
KONGUNADU COLLEGE OF ENGINEERING AND TECHNOLOGY
 
C++ programming introduction
sandeep54552
 
OBJECT ORIENTED PROGRAMING IN C++
Dev Chauhan
 
oop lecture 3
Atif Khan
 
concepts of object and classes in OOPS.pptx
urvashipundir04
 
Ad

Recently uploaded (20)

PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PPTX
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
Quarter 1_PPT_PE & HEALTH 8_WEEK 3-4.pptx
ronajadolpnhs
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PDF
Geographical diversity of India short notes by sandeep swamy
Sandeep Swamy
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PPT-Q1-WEEK-3-SCIENCE-ERevised Matatag Grade 3.pptx
reijhongidayawan02
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Controller Request and Response in Odoo18
Celine George
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Quarter 1_PPT_PE & HEALTH 8_WEEK 3-4.pptx
ronajadolpnhs
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
Geographical diversity of India short notes by sandeep swamy
Sandeep Swamy
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Horarios de distribución de agua en julio
pegazohn1978
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 

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