100% found this document useful (2 votes)
167 views30 pages

Course: C++ Programming Sub Code: 23A: Oops Concept

This document outlines a lecture on object-oriented programming (OOP) concepts for a C++ Programming course. The lecture covers the basic OOP concepts like object, class, encapsulation, data abstraction, inheritance, polymorphism, dynamic binding, and message passing. It provides examples and explanations of each concept. The lecture aims to review C++ introduction, answer preview questions, cover the basic OOP concepts, and conclude the session.

Uploaded by

Thaddeus Moore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
167 views30 pages

Course: C++ Programming Sub Code: 23A: Oops Concept

This document outlines a lecture on object-oriented programming (OOP) concepts for a C++ Programming course. The lecture covers the basic OOP concepts like object, class, encapsulation, data abstraction, inheritance, polymorphism, dynamic binding, and message passing. It provides examples and explanations of each concept. The lecture aims to review C++ introduction, answer preview questions, cover the basic OOP concepts, and conclude the session.

Uploaded by

Thaddeus Moore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 30

Computer

Name
Computer Science
of the
Science Department
Department
Department
: CS ClassI BSc IT IT
: III BSc
BSc CT Even
Even Semester
Semester
Odd Sem 2017
2017 - 18- –1818
2017

Course: C++ Programming Sub Code: 23A

Programme: BSc IT

Unit: I

OOPs Concept

C++ Programming Unit I – Session


Unit I – Session
1 1 OOPs Concept
OOPs Concept 1 1
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

Lecture - Outline
• Review of C++ Introduction
• Preview Questions
• Basic OOPs concept
• Conclusion

C++ Programming Unit I – Session 1 OOPs Concept 2


Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

Review of C++ Introduction


• Structure of c program
• Importance
• Applications

C++ Programming Unit I – Session 1 OOPs Concept 3


Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

Preview Questions
• What is an object?
• Define inheritance.
• What do you mean by polymorphism?

C++ Programming Unit I – Session 1 OOPs Concept 4


Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

Basic concepts of OOP


• Object
• Class
• Encapsulation
• Data Abstraction
• Inheritance
• Polymorphism
• Dynamic Binding
• Message passing

11/21/2018 5
C++ Programming Unit I – Session 1 OOPs Concept 5
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

Object and Class

6
C++ Programming Unit I – Session 1 OOPs Concept 6
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

7
C++ Programming Unit I – Session 1 OOPs Concept 7
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

Encapsulation

8
C++ Programming Unit I – Session 1 OOPs Concept 8
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

9
C++ Programming Unit I – Session 1 OOPs Concept 9
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

Abstraction

10
C++ Programming Unit I – Session 1 OOPs Concept 10
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

Difference between Encapsulation and


Abstraction

11
C++ Programming Unit I – Session 1 OOPs Concept 11
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

Inheritance

SAMSUNG(BASIC
GRAND FATHER
MODEL)

SAMSUNG(ANDROID
FATHER
KITKAT)

SON SAMSUNG(ANDROID
JELLY BEAN)

12
C++ Programming Unit I – Session 1 OOPs Concept 12
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

Polymorphism

13
C++ Programming Unit I – Session 1 OOPs Concept 13
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

Dynamic Binding

14
C++ Programming Unit I – Session 1 OOPs Concept 14
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

Message
One object asks another object to perform an operation.

What is your name?

Professor wang
wang.getName()

Object Oriented Programming /


11/21/2018 15
C++ Programming T.Sangeetha/IT
Unit I – Session 1 OOPs Concept 15
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

• The run-time entities it represent person, thing, a


place, a bank account.
• Real world entities like students, employees,
bank accounts etc.
• They may also represent user-defined data such
as vectors, time and lists
• It may also include hardware and software
components.
• Each object contain data and code to
manipulate data
16
C++ Programming Unit I – Session 1 OOPs Concept 16
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

ways of representing an object

Object name OBJECT NAME

Attribute 1 operation1
Attribute 2
. Attribute 1
. Attribute 2 Operation 2
Attribute N .
.
Operation 1
Operation 2 Attribute N
Operation N
.
.
Operation N

Object Oriented Programming /


11/21/2018 17
C++ Programming Unit I –P.Bhuvaneswari/
Session 1 CSE OOPs Concept 17
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

ways of representing an object

Object : STUDENT

Total
Name DATA
Date-of –birth Name
Marks Date-of birth
Marks
Total()
Average() Average
Display()

Object Oriented Programming /


11/21/2018 18
C++ Programming T.Sangeetha/IT
Unit I – Session 1 OOPs Concept 18
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

Example:
class bank
{
Private:
char name[20];
int accountnumber;
char acctype[4];
float balance;
public:
deposit();
withdraw();
enquire()
}; bank sbi, canara, icici;
Object Oriented Programming /
11/21/2018 19
C++ Programming T.Sangeetha/IT
Unit I – Session 1 OOPs Concept 19
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

Class syntax

Class fruit
{
Char name;//attributes
Char shape;
Char color;
Cost();//operations
};
Fruit banana,orange,pineapple

Object Oriented Programming /


11/21/2018 20
C++ Programming T.Sangeetha/IT
Unit I – Session 1 OOPs Concept 20
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

Inheritance Hierarchy

Vehicle

Automobile Motorcycle Bus

Sedan Sports Car School Bus Luxury Bus

Object Oriented Programming /


11/21/2018 21
C++ Programming T.Sangeetha/IT
Unit I – Session 1 OOPs Concept 21
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

22
C++ Programming Unit I – Session 1 OOPs Concept 22
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

23
C++ Programming Unit I – Session 1 OOPs Concept 23
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

CLASS ENCAPSULATION

INHERITANCE

OBJECTS BASIC CONCEPTS


OF OOPS
DYNAMIC
BINDING

MESSAGE
PASSING ABSTRACTION POLYMORPHISM

11/21/2018 Object Oriented Programming / T.Sangeetha/IT 24


C++ Programming Unit I – Session 1 OOPs Concept 24
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

#include <iostream>
#include <string>
using namespace std;
int main() {
cout << “Hello world! “ << endl;
return 0;
}

25
C++ Programming Unit I – Session 1 OOPs Concept 25
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

Conclusion
• Keywords: Encapsulation, Polymorphism,
Abstraction, Dynamic binding
• Summary:
– Object, class
– Encapsulation, Abstraction
– Inheritance, Polymorphism
– Message passing, Dynamic binding

C++ Programming Unit I – Session 1 OOPs Concept 26


Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

Quiz
• You can use C++ as a procedural, as well as an
object-oriented, language
A. True B. False
• Which of the following concepts means
determining at runtime what method to
invoke?
A. Data hiding
B. Dynamic Typing
C. Dynamic binding
D. Dynamic loading
27
C++ Programming Unit I – Session 1 OOPs Concept 27
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

• Inheritance allow in C++ Program?


– Class Re-usability
– Creating a hierarchy of classes
– Extendibility
– All
• What does your class can hold?
a) data
b) functions
c) both data & functions
d) none of the mentioned

28
C++ Programming Unit I – Session 1 OOPs Concept 28
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

• What is an advantage of polymorphism?


a. The same program logic can be used with objects of
several related types.
b. Variables can be re-used in order to save memory.
c. Constructing new objects from old objects of a similar
type saves time.
d. Polymorphism is a dangerous aspect of inheritance and
should be avoided.

29
C++ Programming Unit I – Session 1 OOPs Concept 29
Computer Science
Computer ScienceDepartment
Department I BSc IT CT
II BSc Even Semester
Odd Sem2017
2017- –1818

Thank You

30
C++ Programming Unit I – Session 1 OOPs Concept 30

You might also like