SlideShare a Scribd company logo
Object Oriented Programming: 2
Elements of Programming
Prof Neeraj Bhargava
Vaibhav Khanna
Department of Computer Science
School of Engineering and Systems Sciences
Maharshi Dayanand Saraswati University Ajmer
Focus of Object oriented Technology
‱ Focus on
– Programming Concepts
– Programming Design Techniques
‱ Don’t get lost in
– Language Technical Details
What is programming?
Programming is taking
A problem
Find the area of a rectangle
A set of data
length
width
A set of functions
area = length * width
Then,
Applying functions to data to solve the
problem
Objects
‱ Objects are an Abstraction
– represent real world entities
– Classes are data types that define shared common properties or attributes
– Objects are instances of a class
‱ Objects have State
– have a value at a particular time
‱ Objects have Operations
– associated set of operations called methods that describe how to carry out
operations
‱ Objects have Messages
– request an object to carry out one of its operations by sending it a
message
– messages are the means by which we exchange data between objects
5
OO Perspective
Let's look at the Rectangle through object oriented eyes:
‱ Define a new type Rectangle (a class)
– Data
‱ width, length
– Function
‱ area()
‱ Create an instance of the class (an object)
‱ Request the object for its area
In C++, rather than writing a procedure, we define a
class that encapsulates the knowledge necessary to
answer the question - here, what is the area of the
rectangle.
6
class Rectangle
{
private:
int width, length;
public:
Rectangle(int w, int l)
{
width = w;
length = l;
}
main()
{
Rectangle rect(3, 5);
cout << rect.area()<<endl;
}
int area()
{
return width*length;
}
};
Example Object Oriented Code
7
Object-Oriented Programming Languages
‱ Characteristics of OOPL:
–Encapsulation
–Inheritance
–Polymorphism
‱ OOPLs support :
– Modular Programming
– Ease of Development
– Maintainability
8
Characteristics of OOPL
‱ Encapsulation: Combining data structure with actions
– Data structure: represents the properties, the state, or characteristics of objects
– Actions: permissible behaviors that are controlled through the member
functions
Data hiding: Process of making certain data inaccessible
‱ Inheritance: Ability to derive new objects from old ones
– permits objects of a more specific class to inherit the properties (data) and
behaviors (functions) of a more general/base class
– ability to define a hierarchical relationship between objects
‱ Polymorphism: Ability for different objects to interpret
functions differently
9
Basic C++
‱ Inherit all ANSI C directives
‱ Inherit all C functions
‱ You don’t have to write OOP programming in
C++
10
Basic C++ Extension from C
‱ comments
/* You can still use the old comment style, */
/* but you must be // very careful about mixing them */
// It's best to use this style for 1 line or partial lines
/* And use this style when your comment
consists of multiple lines */
‱ cin and cout (and #include <iostream.h>)
cout << "hey";
char name[10];
cin >> name;
cout << "Hey " << name << ", nice name." << endl;
cout << endl; // print a blank line
‱ declaring variables almost anywhere
// declare a variable when you need it
for (int k = 1; k < 5; k++){
cout << k;
}
11
Basic C++ Extension from C (II)
‱ const
– In C, #define statement
‱ Preprocessor - No type checking.
‱ #define n 5
– In C++, the const specifier
‱ Compiler - Type checking is applied
‱ const int n = 5; // declare and initialize
‱ New data type
– Reference data type “&”.
int ix; /* ix is "real" variable */
int & rx = ix; /* rx is “alias” for ix. Must initialize*/
ix = 1; /* also rx == 1 */
rx = 2; /* also ix == 2 */
12
C++ - Advance Extension
‱ C++ allows function overloading
– In C++, functions can use the same names, within
the same scope, if each can be distinguished by its
name and signature
– The signature specifies the number, type, and order
of the parameters expressed as a comma separated
list of argument types
13
C++
‱ Is a better C
‱ Expressive
‱ Supports Data Abstraction
‱ Supports OOP
‱ Supports Generic Programming
– Containers
‱ Stack of char, int, double etc
– Generic Algorithms
‱ sort(), copy(), search() any container Stack/Vector/List
14
Take Home Message
‱ There are many different kinds of programming
paradigms, OOP is one among them.
‱ In OOP, programmers see the execution of the
program as a collection of dialoging objects.
‱ The main characteristics of OOPL include
encapsulation, inheritance, and polymorphism.
Assignment
‱ Explain the concept and Methodology of
Object Oriented Programming in C++

More Related Content

PPTX
NHibernate for .NET
PDF
Object Oriented Programming Concepts
 
PPT
Introduction to NHibernate
PPTX
OOPS features using Objective C
PDF
Concepts of OOPs
PPT
Basic concepts of oops
PPTX
Object Oriented Technologies
PPT
wrapper classes
NHibernate for .NET
Object Oriented Programming Concepts
 
Introduction to NHibernate
OOPS features using Objective C
Concepts of OOPs
Basic concepts of oops
Object Oriented Technologies
wrapper classes

What's hot (15)

PPTX
Applications of data structures
 
PPSX
Collections - Sorting, Comparing Basics
PPTX
Regular Expressions
PPSX
Strings in Java
PDF
HypergraphDB
PPT
Designing A Syntax Based Retrieval System03
PPTX
PPTX
Spatial
PPT
Data structures
PPT
C plusplus
PPTX
Data structure and algorithm using java
PPTX
Data structures and algorithms
PPTX
32sql server
PPTX
Object oriented programming concepts
PPTX
30csharp
Applications of data structures
 
Collections - Sorting, Comparing Basics
Regular Expressions
Strings in Java
HypergraphDB
Designing A Syntax Based Retrieval System03
Spatial
Data structures
C plusplus
Data structure and algorithm using java
Data structures and algorithms
32sql server
Object oriented programming concepts
30csharp
Ad

Similar to Object oriented programming 2 elements of programming (20)

PPT
Fundamentals of Programming in C++.ppt
PPT
PDF
M.c.a (sem iii) paper - i - object oriented programming
PDF
C++
PDF
C++ [ principles of object oriented programming ]
PPTX
Lecture 1.pptx
PPTX
OOP CHAPTER object oreinted programming using c++
PPTX
Object Oriented Programming beigneers Lecture 01 (1).pptx
PPTX
OOP Unit 1 - Foundation of Object- Oriented Programming
PPTX
OODP Unit 1 OOPs classes and objects
PPTX
Object Oriented Programming Lecture 01.pptx
PPTX
C++ & Data Structure - Unit - first.pptx
PDF
OOPS_Unit_1
PDF
Object Oriented Programming With C 2140705 Darshan All Unit Darshan Institute...
DOCX
Cs6301 programming and datastactures
PPTX
CPP_,module2_1.pptx
PPTX
An introduction to object-oriented programming.pptx
PPTX
object oriented programming language in c++
PPT
Bca 2nd sem u-1 iintroduction
Fundamentals of Programming in C++.ppt
M.c.a (sem iii) paper - i - object oriented programming
C++
C++ [ principles of object oriented programming ]
Lecture 1.pptx
OOP CHAPTER object oreinted programming using c++
Object Oriented Programming beigneers Lecture 01 (1).pptx
OOP Unit 1 - Foundation of Object- Oriented Programming
OODP Unit 1 OOPs classes and objects
Object Oriented Programming Lecture 01.pptx
C++ & Data Structure - Unit - first.pptx
OOPS_Unit_1
Object Oriented Programming With C 2140705 Darshan All Unit Darshan Institute...
Cs6301 programming and datastactures
CPP_,module2_1.pptx
An introduction to object-oriented programming.pptx
object oriented programming language in c++
Bca 2nd sem u-1 iintroduction
Ad

More from Vaibhav Khanna (20)

PPTX
Information and network security 47 authentication applications
PPTX
Information and network security 46 digital signature algorithm
PPTX
Information and network security 45 digital signature standard
PPTX
Information and network security 44 direct digital signatures
PPTX
Information and network security 43 digital signatures
PPTX
Information and network security 42 security of message authentication code
PPTX
Information and network security 41 message authentication code
PPTX
Information and network security 40 sha3 secure hash algorithm
PPTX
Information and network security 39 secure hash algorithm
PPTX
Information and network security 38 birthday attacks and security of hash fun...
PPTX
Information and network security 37 hash functions and message authentication
PPTX
Information and network security 35 the chinese remainder theorem
PPTX
Information and network security 34 primality
PPTX
Information and network security 33 rsa algorithm
PPTX
Information and network security 32 principles of public key cryptosystems
PPTX
Information and network security 31 public key cryptography
PPTX
Information and network security 30 random numbers
PPTX
Information and network security 29 international data encryption algorithm
PPTX
Information and network security 28 blowfish
PPTX
Information and network security 27 triple des
Information and network security 47 authentication applications
Information and network security 46 digital signature algorithm
Information and network security 45 digital signature standard
Information and network security 44 direct digital signatures
Information and network security 43 digital signatures
Information and network security 42 security of message authentication code
Information and network security 41 message authentication code
Information and network security 40 sha3 secure hash algorithm
Information and network security 39 secure hash algorithm
Information and network security 38 birthday attacks and security of hash fun...
Information and network security 37 hash functions and message authentication
Information and network security 35 the chinese remainder theorem
Information and network security 34 primality
Information and network security 33 rsa algorithm
Information and network security 32 principles of public key cryptosystems
Information and network security 31 public key cryptography
Information and network security 30 random numbers
Information and network security 29 international data encryption algorithm
Information and network security 28 blowfish
Information and network security 27 triple des

Recently uploaded (20)

PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
System and Network Administration Chapter 2
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Nekopoi APK 2025 free lastest update
PDF
AI in Product Development-omnex systems
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Wondershare Filmora 15 Crack With Activation Key [2025
Internet Downloader Manager (IDM) Crack 6.42 Build 41
2025 Textile ERP Trends: SAP, Odoo & Oracle
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Adobe Illustrator 28.6 Crack My Vision of Vector Design
System and Network Administration Chapter 2
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Odoo POS Development Services by CandidRoot Solutions
How to Choose the Right IT Partner for Your Business in Malaysia
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Upgrade and Innovation Strategies for SAP ERP Customers
Nekopoi APK 2025 free lastest update
AI in Product Development-omnex systems
PTS Company Brochure 2025 (1).pdf.......
Design an Analysis of Algorithms II-SECS-1021-03
Navsoft: AI-Powered Business Solutions & Custom Software Development
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...

Object oriented programming 2 elements of programming

  • 1. Object Oriented Programming: 2 Elements of Programming Prof Neeraj Bhargava Vaibhav Khanna Department of Computer Science School of Engineering and Systems Sciences Maharshi Dayanand Saraswati University Ajmer
  • 2. Focus of Object oriented Technology ‱ Focus on – Programming Concepts – Programming Design Techniques ‱ Don’t get lost in – Language Technical Details
  • 3. What is programming? Programming is taking A problem Find the area of a rectangle A set of data length width A set of functions area = length * width Then, Applying functions to data to solve the problem
  • 4. Objects ‱ Objects are an Abstraction – represent real world entities – Classes are data types that define shared common properties or attributes – Objects are instances of a class ‱ Objects have State – have a value at a particular time ‱ Objects have Operations – associated set of operations called methods that describe how to carry out operations ‱ Objects have Messages – request an object to carry out one of its operations by sending it a message – messages are the means by which we exchange data between objects
  • 5. 5 OO Perspective Let's look at the Rectangle through object oriented eyes: ‱ Define a new type Rectangle (a class) – Data ‱ width, length – Function ‱ area() ‱ Create an instance of the class (an object) ‱ Request the object for its area In C++, rather than writing a procedure, we define a class that encapsulates the knowledge necessary to answer the question - here, what is the area of the rectangle.
  • 6. 6 class Rectangle { private: int width, length; public: Rectangle(int w, int l) { width = w; length = l; } main() { Rectangle rect(3, 5); cout << rect.area()<<endl; } int area() { return width*length; } }; Example Object Oriented Code
  • 7. 7 Object-Oriented Programming Languages ‱ Characteristics of OOPL: –Encapsulation –Inheritance –Polymorphism ‱ OOPLs support : – Modular Programming – Ease of Development – Maintainability
  • 8. 8 Characteristics of OOPL ‱ Encapsulation: Combining data structure with actions – Data structure: represents the properties, the state, or characteristics of objects – Actions: permissible behaviors that are controlled through the member functions Data hiding: Process of making certain data inaccessible ‱ Inheritance: Ability to derive new objects from old ones – permits objects of a more specific class to inherit the properties (data) and behaviors (functions) of a more general/base class – ability to define a hierarchical relationship between objects ‱ Polymorphism: Ability for different objects to interpret functions differently
  • 9. 9 Basic C++ ‱ Inherit all ANSI C directives ‱ Inherit all C functions ‱ You don’t have to write OOP programming in C++
  • 10. 10 Basic C++ Extension from C ‱ comments /* You can still use the old comment style, */ /* but you must be // very careful about mixing them */ // It's best to use this style for 1 line or partial lines /* And use this style when your comment consists of multiple lines */ ‱ cin and cout (and #include <iostream.h>) cout << "hey"; char name[10]; cin >> name; cout << "Hey " << name << ", nice name." << endl; cout << endl; // print a blank line ‱ declaring variables almost anywhere // declare a variable when you need it for (int k = 1; k < 5; k++){ cout << k; }
  • 11. 11 Basic C++ Extension from C (II) ‱ const – In C, #define statement ‱ Preprocessor - No type checking. ‱ #define n 5 – In C++, the const specifier ‱ Compiler - Type checking is applied ‱ const int n = 5; // declare and initialize ‱ New data type – Reference data type “&”. int ix; /* ix is "real" variable */ int & rx = ix; /* rx is “alias” for ix. Must initialize*/ ix = 1; /* also rx == 1 */ rx = 2; /* also ix == 2 */
  • 12. 12 C++ - Advance Extension ‱ C++ allows function overloading – In C++, functions can use the same names, within the same scope, if each can be distinguished by its name and signature – The signature specifies the number, type, and order of the parameters expressed as a comma separated list of argument types
  • 13. 13 C++ ‱ Is a better C ‱ Expressive ‱ Supports Data Abstraction ‱ Supports OOP ‱ Supports Generic Programming – Containers ‱ Stack of char, int, double etc – Generic Algorithms ‱ sort(), copy(), search() any container Stack/Vector/List
  • 14. 14 Take Home Message ‱ There are many different kinds of programming paradigms, OOP is one among them. ‱ In OOP, programmers see the execution of the program as a collection of dialoging objects. ‱ The main characteristics of OOPL include encapsulation, inheritance, and polymorphism.
  • 15. Assignment ‱ Explain the concept and Methodology of Object Oriented Programming in C++