SlideShare una empresa de Scribd logo
1 de 26
AbdulRaouf N
arn.raouf@gmail.com
www.facebook.com/AbdulRaouf
twitter.com/username
in.linkedin.com/in/profilename
OOP CONCEPTS
Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
OOP CONCEPT
• Object-oriented programming (OOP) is a style of
programming that focuses on using objects to design
and build applications.
• Think of an object as a model of the concepts,
processes, or things in the real world that are
meaningful to your application
OBJECT
• Which will have a name as identity
• Properties to define its behaviour
• Actions what it can perform
• It has two main properties:
– State: the object encapsulates information about
itself - attributes or fields.
– Behaviour: the object can do some things on
behalf of other objects – methods.
OBJECT(contd)
• Example:
In a banking system, a particular bank account is an
example of an object.
– Its state consists of attributes like: owner, account
number, balance, etc.
– Its behaviours consist of: deposit, withdraw, etc.
CLASS
• We need to create a base design which defines the
properties and functionalities that the object should
have.
• In programming terms we call this base design as
Class.
• We can create any number of objects from a class.
• Each individual object is called an instance of its
class.
CLASS(contd)
• The actions that can be performed by objects become
functions of the class and is referred to as Methods.
• No memory is allocated when a class is created. Memory
is allocated only when an object is created.
• Example:
Banking system is an example for class.
Different accounts are example for objects.
How to create class in C++
class shape //create a class
{
public: Int width;
Int height;
Int calculateArea()
{
return x*y
}
}
ATTRIBUTES
Contain current state of an object.
• Attributes can be classified as simple or complex.
• Simple attribute can be a primitive type such as
integer, string, etc.
• Complex attribute can contain collections and/or
references.
• Complex object: contains one or more complex
attributes
METHODS
• Defines behavior of an object, as a set of
encapsulated functions.
• The class describes those methods.
• It defines what an object can do.
INHERITANCE
 Inheritance allows child classes inherits the
characteristics of existing parent class.
• Attributes (fields and properties)
• Operations (methods)
 Child class can extend the parent class.
• Add new fields and methods
• Redefine methods (modify existing behavior)
INHERITANCE-Example/* C++ Program to calculate the area of rectangles using concept of inheritance.
#include <iostream>
using namespace std;
class Rectangle{
protected:float length, breadth;
public:
Rectangle(): length(0.0), breadth(0.0){
cout<<"Enter length: "; cin>>length;
cout<<"Enter breadth: "; cin>>breadth;
}};
/* Area class is derived from base class Rectangle. */
class Area : public Rectangle{
public:
float calc(){
return length*breadth;
}};
int main(){
cout<<"Enter data for rectangle to find area.n";
Area a;
cout<<"Area = "<<a.calc()<<" square meternn";
return 0;
}
ABSTRACTION
• Abstraction means ignoring irrelevant features,
properties, or functions and emphasizing the
relevant ones.
• Abstraction = managing complexity.
• Allows us to represent a complex reality in terms of a
simplified model.
• Abstraction highlights the properties of an entity that
we need and hides the others.
ENCAPSULATION
• Encapsulation hides the implementation
details
• Class announces some operations (methods)
available for its clients – its public interface
• All data members (fields) of a class should be
hidden-Accessed via properties (read-only and
read-write)
Example for Abstraction and Encapsulation
#include <iostream>
using namespace std;
class Adder{
public:// constructor
Adder(int i = 0){
total = i;}
// interface to outside world
void addNum(int number){
total += number;}
// interface to outside world
int getTotal(){
return total;};
private:// hidden data from outside world
int total;};
int main( ){
Adder a;
a.addNum(10); a.addNum(20); a.addNum(30);
cout << "Total " << a.getTotal() <<endl;
return 0;
}
POLYMORPHISM
• Polymorphism is the ability to take more than
one form.
• Polymorphism allows abstract operations to
be defined and used.
• Polymorphism allows routines to use variables
of different types at different times.
Example for Polymorphism
#include <iostream>
using namespace std;
class Shape { protected:int width, height;
public: Shape( int a=0, int b=0) { width = a; height = b; }
int area() { cout << "Parent class area :" <<endl; return 0; } } ;
class Rectangle: public Shape{
public:Rectangle( int a=0, int b=0):Shape(a, b) { }
int area (){
cout << "Rectangle class area :" <<endl; return (width * height);}};
class Triangle: public Shape{
public:Triangle( int a=0, int b=0):Shape(a, b) { }
int area (){
cout << "Triangle class area :" <<endl; return (width * height / 2);}};
// Main function for the program
int main( ){
Shape *shape; Rectangle rec(10,7); Triangle tri(10,5);
// store the address of Rectangle
shape = &rec;
// call rectangle area.
shape->area();
// store the address of Triangle
shape = &tri;
// call triangle area.
shape->area();
return 0; }
FUNCTION OVERLOADING
• It is simply defined as the ability of one
function to perform different tasks.
• For example, doTask() and doTask(object O)
are overloaded methods.
• To call the latter, an object must be passed as
a parameter, whereas the former does not
require a parameter, and is called with an
empty parameter field.
Example for Function Overloading
#include <iostream>
// volume of a cube
int volume(int s){
return s*s*s;
}
// volume of a triangle
float volume(int b, int h){
return 0.5*b*h;
}
// volume of a cuboid
long volume(long l, int b, int h){
return l*b*h;
}
int main(){
std::cout << volume(10);
std::cout << volume(9, 7);
std::cout << volume(100, 75, 15);
}
In the above example, the volume of various components are calculated using the same function
call "volume", with arguments differing in their data type or their number.
OPERATOR OVERLOADING
• Different operators have different
implementations depending on their
arguments.
• Operator overloading is generally defined by
the language, the programmer, or both.
• We can redefine or overload most of the built-
in operators available in C++.
Example for Operator Overloading
#include<iostream>
class complex
{
public: int real,imaginary;
complex operator+(complex ob)
{
complex t;
t.real=real+ob.real;
t.imaginary=imaginary+ob.imaginary;
return(t);
}
};
int main()
{
complex obj1,obj2,result;
obj1.real=12; obj2.imaginary=3;
obj2.real=8; obj2.imaginary=1;
result=obj1+obj2 // result=obj1.operator+(obj2);
cout<<result.real<<result.imaginary;
return 0;
}
THANK YOU
Want to learn more about programming or Looking to become a good programmer?
Are you wasting time on searching so many contents online?
Do you want to learn things quickly?
Tired of spending huge amount of money to become a Software professional?
Do an online course
@ baabtra.com
We put industry standards to practice. Our structured, activity based courses are so designed
to make a quick, good software professional out of anybody who holds a passion for coding.
Follow us @ twitter.com/baabtra
Like us @ facebook.com/baabtra
Subscribe to us @ youtube.com/baabtra
Become a follower @ slideshare.net/BaabtraMentoringPartner
Connect to us @ in.linkedin.com/in/baabtra
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Cafit Square,
Hilite Business Park,
Near Pantheerankavu,
Kozhikode
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com

Más contenido relacionado

La actualidad más candente

standard template library(STL) in C++
standard template library(STL) in C++standard template library(STL) in C++
standard template library(STL) in C++•sreejith •sree
 
Python Class | Python Programming | Python Tutorial | Edureka
Python Class | Python Programming | Python Tutorial | EdurekaPython Class | Python Programming | Python Tutorial | Edureka
Python Class | Python Programming | Python Tutorial | EdurekaEdureka!
 
Polymorphism in java
Polymorphism in java Polymorphism in java
Polymorphism in java Janu Jahnavi
 
Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.MASQ Technologies
 
Dynamic memory allocation in c++
Dynamic memory allocation in c++Dynamic memory allocation in c++
Dynamic memory allocation in c++Tech_MX
 
Templates in C++
Templates in C++Templates in C++
Templates in C++Tech_MX
 
Encapsulation in C++
Encapsulation in C++Encapsulation in C++
Encapsulation in C++Hitesh Kumar
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingMoutaz Haddara
 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance pptNivegeetha
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Michelle Anne Meralpis
 

La actualidad más candente (20)

standard template library(STL) in C++
standard template library(STL) in C++standard template library(STL) in C++
standard template library(STL) in C++
 
Function in C
Function in CFunction in C
Function in C
 
Python Class | Python Programming | Python Tutorial | Edureka
Python Class | Python Programming | Python Tutorial | EdurekaPython Class | Python Programming | Python Tutorial | Edureka
Python Class | Python Programming | Python Tutorial | Edureka
 
Oops in Java
Oops in JavaOops in Java
Oops in Java
 
Polymorphism in java
Polymorphism in java Polymorphism in java
Polymorphism in java
 
Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.
 
Dynamic memory allocation in c++
Dynamic memory allocation in c++Dynamic memory allocation in c++
Dynamic memory allocation in c++
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
Introduction to OOP(in java) BY Govind Singh
Introduction to OOP(in java)  BY Govind SinghIntroduction to OOP(in java)  BY Govind Singh
Introduction to OOP(in java) BY Govind Singh
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Class and object
Class and objectClass and object
Class and object
 
Encapsulation in C++
Encapsulation in C++Encapsulation in C++
Encapsulation in C++
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance ppt
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
Chapter 07 inheritance
Chapter 07 inheritanceChapter 07 inheritance
Chapter 07 inheritance
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Python OOPs
Python OOPsPython OOPs
Python OOPs
 
Java Basic Oops Concept
Java Basic Oops ConceptJava Basic Oops Concept
Java Basic Oops Concept
 
Inheritance C#
Inheritance C#Inheritance C#
Inheritance C#
 

Destacado

Object oriented programming concept
Object oriented programming conceptObject oriented programming concept
Object oriented programming conceptPina Parmar
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops conceptsNilesh Dalvi
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programmingNeelesh Shukla
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Conceptsthinkphp
 

Destacado (8)

Oop concepts
Oop conceptsOop concepts
Oop concepts
 
Oop concept
Oop conceptOop concept
Oop concept
 
General OOP concept [by-Digvijay]
General OOP concept [by-Digvijay]General OOP concept [by-Digvijay]
General OOP concept [by-Digvijay]
 
Object oriented programming concept
Object oriented programming conceptObject oriented programming concept
Object oriented programming concept
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programming
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 

Similar a Oop concepts (20)

Lecture02
Lecture02Lecture02
Lecture02
 
Oop concept
Oop conceptOop concept
Oop concept
 
Oops concept
Oops conceptOops concept
Oops concept
 
Bc0037
Bc0037Bc0037
Bc0037
 
Oop concept in c++ by MUhammed Thanveer Melayi
Oop concept in c++ by MUhammed Thanveer MelayiOop concept in c++ by MUhammed Thanveer Melayi
Oop concept in c++ by MUhammed Thanveer Melayi
 
OOC MODULE1.pptx
OOC MODULE1.pptxOOC MODULE1.pptx
OOC MODULE1.pptx
 
Unit3_OOP-converted.pdf
Unit3_OOP-converted.pdfUnit3_OOP-converted.pdf
Unit3_OOP-converted.pdf
 
Ch.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objectsCh.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objects
 
classes & objects.ppt
classes & objects.pptclasses & objects.ppt
classes & objects.ppt
 
c++ Unit I.pptx
c++ Unit I.pptxc++ Unit I.pptx
c++ Unit I.pptx
 
Presentation 4th
Presentation 4thPresentation 4th
Presentation 4th
 
3. Polymorphism.pptx
3. Polymorphism.pptx3. Polymorphism.pptx
3. Polymorphism.pptx
 
Oops lecture 1
Oops lecture 1Oops lecture 1
Oops lecture 1
 
2nd puc computer science chapter 8 function overloading
 2nd puc computer science chapter 8   function overloading 2nd puc computer science chapter 8   function overloading
2nd puc computer science chapter 8 function overloading
 
Object oriented programming 2
Object oriented programming 2Object oriented programming 2
Object oriented programming 2
 
14 operator overloading
14 operator overloading14 operator overloading
14 operator overloading
 
21CSC101T best ppt ever OODP UNIT-2.pptx
21CSC101T best ppt ever OODP UNIT-2.pptx21CSC101T best ppt ever OODP UNIT-2.pptx
21CSC101T best ppt ever OODP UNIT-2.pptx
 
oops.pptx
oops.pptxoops.pptx
oops.pptx
 
Object Oriented Programming using C++(UNIT 1)
Object Oriented Programming using C++(UNIT 1)Object Oriented Programming using C++(UNIT 1)
Object Oriented Programming using C++(UNIT 1)
 
Chapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-classChapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-class
 

Más de baabtra.com - No. 1 supplier of quality freshers

Más de baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 

Último

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 

Último (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Oop concepts

  • 1.
  • 3. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  • 4. OOP CONCEPT • Object-oriented programming (OOP) is a style of programming that focuses on using objects to design and build applications. • Think of an object as a model of the concepts, processes, or things in the real world that are meaningful to your application
  • 5. OBJECT • Which will have a name as identity • Properties to define its behaviour • Actions what it can perform • It has two main properties: – State: the object encapsulates information about itself - attributes or fields. – Behaviour: the object can do some things on behalf of other objects – methods.
  • 6. OBJECT(contd) • Example: In a banking system, a particular bank account is an example of an object. – Its state consists of attributes like: owner, account number, balance, etc. – Its behaviours consist of: deposit, withdraw, etc.
  • 7. CLASS • We need to create a base design which defines the properties and functionalities that the object should have. • In programming terms we call this base design as Class. • We can create any number of objects from a class. • Each individual object is called an instance of its class.
  • 8. CLASS(contd) • The actions that can be performed by objects become functions of the class and is referred to as Methods. • No memory is allocated when a class is created. Memory is allocated only when an object is created. • Example: Banking system is an example for class. Different accounts are example for objects.
  • 9. How to create class in C++ class shape //create a class { public: Int width; Int height; Int calculateArea() { return x*y } }
  • 10. ATTRIBUTES Contain current state of an object. • Attributes can be classified as simple or complex. • Simple attribute can be a primitive type such as integer, string, etc. • Complex attribute can contain collections and/or references. • Complex object: contains one or more complex attributes
  • 11. METHODS • Defines behavior of an object, as a set of encapsulated functions. • The class describes those methods. • It defines what an object can do.
  • 12. INHERITANCE  Inheritance allows child classes inherits the characteristics of existing parent class. • Attributes (fields and properties) • Operations (methods)  Child class can extend the parent class. • Add new fields and methods • Redefine methods (modify existing behavior)
  • 13. INHERITANCE-Example/* C++ Program to calculate the area of rectangles using concept of inheritance. #include <iostream> using namespace std; class Rectangle{ protected:float length, breadth; public: Rectangle(): length(0.0), breadth(0.0){ cout<<"Enter length: "; cin>>length; cout<<"Enter breadth: "; cin>>breadth; }}; /* Area class is derived from base class Rectangle. */ class Area : public Rectangle{ public: float calc(){ return length*breadth; }}; int main(){ cout<<"Enter data for rectangle to find area.n"; Area a; cout<<"Area = "<<a.calc()<<" square meternn"; return 0; }
  • 14. ABSTRACTION • Abstraction means ignoring irrelevant features, properties, or functions and emphasizing the relevant ones. • Abstraction = managing complexity. • Allows us to represent a complex reality in terms of a simplified model. • Abstraction highlights the properties of an entity that we need and hides the others.
  • 15. ENCAPSULATION • Encapsulation hides the implementation details • Class announces some operations (methods) available for its clients – its public interface • All data members (fields) of a class should be hidden-Accessed via properties (read-only and read-write)
  • 16. Example for Abstraction and Encapsulation #include <iostream> using namespace std; class Adder{ public:// constructor Adder(int i = 0){ total = i;} // interface to outside world void addNum(int number){ total += number;} // interface to outside world int getTotal(){ return total;}; private:// hidden data from outside world int total;}; int main( ){ Adder a; a.addNum(10); a.addNum(20); a.addNum(30); cout << "Total " << a.getTotal() <<endl; return 0; }
  • 17. POLYMORPHISM • Polymorphism is the ability to take more than one form. • Polymorphism allows abstract operations to be defined and used. • Polymorphism allows routines to use variables of different types at different times.
  • 18. Example for Polymorphism #include <iostream> using namespace std; class Shape { protected:int width, height; public: Shape( int a=0, int b=0) { width = a; height = b; } int area() { cout << "Parent class area :" <<endl; return 0; } } ; class Rectangle: public Shape{ public:Rectangle( int a=0, int b=0):Shape(a, b) { } int area (){ cout << "Rectangle class area :" <<endl; return (width * height);}}; class Triangle: public Shape{ public:Triangle( int a=0, int b=0):Shape(a, b) { } int area (){ cout << "Triangle class area :" <<endl; return (width * height / 2);}}; // Main function for the program int main( ){ Shape *shape; Rectangle rec(10,7); Triangle tri(10,5); // store the address of Rectangle shape = &rec; // call rectangle area. shape->area(); // store the address of Triangle shape = &tri; // call triangle area. shape->area(); return 0; }
  • 19. FUNCTION OVERLOADING • It is simply defined as the ability of one function to perform different tasks. • For example, doTask() and doTask(object O) are overloaded methods. • To call the latter, an object must be passed as a parameter, whereas the former does not require a parameter, and is called with an empty parameter field.
  • 20. Example for Function Overloading #include <iostream> // volume of a cube int volume(int s){ return s*s*s; } // volume of a triangle float volume(int b, int h){ return 0.5*b*h; } // volume of a cuboid long volume(long l, int b, int h){ return l*b*h; } int main(){ std::cout << volume(10); std::cout << volume(9, 7); std::cout << volume(100, 75, 15); } In the above example, the volume of various components are calculated using the same function call "volume", with arguments differing in their data type or their number.
  • 21. OPERATOR OVERLOADING • Different operators have different implementations depending on their arguments. • Operator overloading is generally defined by the language, the programmer, or both. • We can redefine or overload most of the built- in operators available in C++.
  • 22. Example for Operator Overloading #include<iostream> class complex { public: int real,imaginary; complex operator+(complex ob) { complex t; t.real=real+ob.real; t.imaginary=imaginary+ob.imaginary; return(t); } }; int main() { complex obj1,obj2,result; obj1.real=12; obj2.imaginary=3; obj2.real=8; obj2.imaginary=1; result=obj1+obj2 // result=obj1.operator+(obj2); cout<<result.real<<result.imaginary; return 0; }
  • 24. Want to learn more about programming or Looking to become a good programmer? Are you wasting time on searching so many contents online? Do you want to learn things quickly? Tired of spending huge amount of money to become a Software professional? Do an online course @ baabtra.com We put industry standards to practice. Our structured, activity based courses are so designed to make a quick, good software professional out of anybody who holds a passion for coding.
  • 25. Follow us @ twitter.com/baabtra Like us @ facebook.com/baabtra Subscribe to us @ youtube.com/baabtra Become a follower @ slideshare.net/BaabtraMentoringPartner Connect to us @ in.linkedin.com/in/baabtra Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  • 26. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Cafit Square, Hilite Business Park, Near Pantheerankavu, Kozhikode Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com