SlideShare a Scribd company logo
College of applied Business(CAB) And Technology
Course Name
Object Oriented Programming (CSC-161)
Faculty Name
Mr. Tekendra Nath Yogi
Tekendranath@gmail.com
Course Title: Design and Analysis of Algorithms
• Course no: CSC- 161 Full Marks: 60+20+ 20
• Credit hours: 3 Pass Marks: 24+ 8 +8
• Nature of course: Theory + Lab
• Course Description:
– The course covers the basic concepts of object oriented programming using
C++ programming language.
• Course Objectives:
– The main objective of this course is to understand object oriented
programming and advanced C++ concepts such as composition of objects,
operator overloads, inheritance and polymorphism, file I/O, exception handling
and templates.
2Presented By: Tekendra Nath Yogi
Course Contents:
• Unit 1: Introduction to Object Oriented Programming (3 Hrs.)
– Overview of structured programming approach.
– Problems with structured programming.
– Object oriented programming approach
– Characteristics of object oriented languages
• Objects
• Classes
• Data abstraction and encapsulation
• Polymorphism
• Overloading
• inheritance
3Presented By: Tekendra Nath Yogi
Contd…
• Unit 2: Basics of C++ programming (5 Hrs.)
– C++ Program Structure
– Character Set and Tokens(Keywords, identifiers, constants,
operators, special symbols)
– Data Type ( Basic types, derived types, and user defined types)
– Type Conversion( Explicit conversion(Type cast operator), Implicit
conversion)
– Preprocessor Directives( include and define directives)
4Presented By: Tekendra Nath Yogi
Contd…
• Namespace
• Input/Output Streams (Cin and Cout) and Manipulators ( setw and endl)
• Dynamic Memory Allocation with new and delete
• Control Statements(abstract review of decision making and branching,
decision making and looping).
• Functions: Function Overloading (different number of arguments, different
types of argument)
• Inline Functions
• Default Argument
• Pass by Reference
• Return by Reference
5Presented By: Tekendra Nath Yogi
Contd…
• Scope (local, file, and class) and Storage Class.
• Pointers: Pointer variables declaration & initialization, Operators
in pointers(Address-of and value-at- the- address)
• Pointers and Arrays,
• Pointer and Function(Passing simple variables, passing arrays).
6Presented By: Tekendra Nath Yogi
Contd…
• Unit 3: Classes & Objects (8 Hrs.)
– A Simple Class and Object (class definition: data member and
function member)
– Accessing members of class
– Initialization of class objects: (Constructor, Destructor)
– Default Constructor, Parameterized Constructor, Copy Constructor,
The Default Copy Constructor,
– destructor
7Presented By: Tekendra Nath Yogi
Contd…
– Objects as Function Arguments,
– Returning Objects from Functions,
– Structures and Classes,
– Memory allocation for Objects,
– Static members,
– Member functions defined outside the class (Using scope resolution
operator).
8Presented By: Tekendra Nath Yogi
Contd…
• Unit 4: Operator Overloading (7 Hrs.)
– Fundamental of operator overloading, Restriction on
operator overloading, Operator functions as a class
members,
– Overloading unary and binary operator,
– Data Conversion (basic to basic, basic to user-defined,
user-defined to basic, user-defined to user-defined)
9Presented By: Tekendra Nath Yogi
Contd…
• Unit 5: Inheritance (7 Hrs.)
– Introduction to inheritance, Derived Class and Base Class,
– Access Specifiers (private, protected, and public),
– Types of inheritance(simple, multiple, hierarchical, multi-level,
hybrid)
– Public and Private Inheritance,
– Constructor and Destructor in derived classes,
– Aggregation (class with in class)
10Presented By: Tekendra Nath Yogi
Contd…
• Unit 6: Virtual Function, Polymorphism, and miscellaneous C++ Features (5 Hrs.)
– Concept of Virtual functions (difference between normal member function accessed with pointers
and virtual member function accessed with pointer)
– Late Binding, Abstract class and pure virtual functions
– Virtual Destructors, Virtual base class
– Friend function(friend class) and Static function,
– Assignment and copy initialization, Copy constructor,
– This pointer,
– Concrete classes(vs. abstract class),
– Polymorphism and its roles.
11Presented By: Tekendra Nath Yogi
Contd…
• Unit 7: Function Templates and Exception Handling (4 Hrs.)
– Function templates
– Function templates with multiple arguments
– Class templates
– templates and inheritance
– Exceptional Handling (Try, throw and catch)
– Use of exceptional handling.
12Presented By: Tekendra Nath Yogi
Contd…
• Unit 8: File handling (6 Hrs.)
– Stream Class Hierarchy for Console Input /Output,
– Unformatted Input /Output,
– Formatted Input /Output with ios Member functions,
– Formatting with Manipulators,
– Stream Operator Overloading,
– File Input/output with Streams,
13Presented By: Tekendra Nath Yogi
Contd…
– Opening and Closing files (open() and close() member function)
– Read/Write from File ( put() and get(), read(), and write(), member
functions)
– File Access Pointers and their Manipulators (seeks(), seekp(),
tellg(), tellP(), offset, and etc..)
– Sequential and Random Access to File,
– Testing Errors during File Operations (eof(), fail(),bad(), good())
14Presented By: Tekendra Nath Yogi
Laboratory Works
• Students should be able to implement the concepts of Object
Oriented Programming using C++ language.
15Presented By: Tekendra Nath Yogi
Text Books
• Robert Lafore, Object Oriented Programming in C++, Fourth Edition, SAMS
publications.
• Herbert Schildt, C++ The Complete Reference, Fourth Edition, Tata McGraw
Hill Publication.
16Presented By: Tekendra Nath Yogi
Reference Books
• Deitel and Deitel, C++ How to Program, Third Edition, Pearson Publication.
• Joyce Farrell, Object-oriented programming using C++, Fourth Edition,
Cengage Learning.
17Presented By: Tekendra Nath Yogi
Model Question F.M.: 60
P.M.: 24
Section A(Long Answer questions): Attempt any two questions [2*10= 20]
– 1.
– 2.
– 3.
• Section B(Short Answer questions): Attempt any eight questions [8*5=40]
– 4.
– 5.
– 6.
– 7.
– 8.
– 9.
– 10.
– 11.
– 12.
18Presented By: Tekendra Nath Yogi
Unit1: Introduction to objected oriented programming
• Programming:
– The art and science of creating programs
– Art: application of human creative skill and imagination.
– Science: systematic study through observation and experiment.
• So, to be a good programmer you should do a lot of experiment
and observation of programs by using your own creative skill
and imagination.
19Presented By: Tekendra Nath Yogi
Contd…
• Program:
– Program outlines exactly the steps needed to perform
a certain task.
– E.g., Add two numbers
20Presented By: Tekendra Nath Yogi
Contd…
• Programming language:
– A programming language is a tool used by
programmers for instructing a computer or computing
device to perform specific tasks.
21Presented By: Tekendra Nath Yogi
Contd…
• Classification Of Programming Languages:
– Machine Language:
• use 0 and 1 to express the instructions to perform a certain
task.
– Assembly Language:
• This language uses symbols to express the instructions to
perform the certain task.
– High-level language:
• This language uses mostly high level language like statement
to express the instructions to perform a certain task.
22Presented By: Tekendra Nath Yogi
Contd..
• The Top Programming Languages?
– IEEE Ranking of programming language:
23Presented By: Tekendra Nath Yogi
Programming Paradigms
• Program organizing principles are called programming
paradigms.
• Following are the five types of programming paradigm:
– Unstructured programming
– Procedural programming
– Structured programming
– Object-oriented programming
– Object-based programming
24Presented By: Tekendra Nath Yogi
Contd…
• Unstructured Programming paradigm:
– A Technique for organizing and coding computer
programs in which programmers put all their code in
one program.
25Presented By: Tekendra Nath Yogi
Contd…
• This programming technique provides tremendous
disadvantages (duplicacy and redundancy of code, code
maintenance problem, readability and many more ) once the
program gets sufficiently large
• For example, if the same statement sequence is needed at
different locations within the program, the sequence must be
copied.
• This has lead to the idea of extracting these sequences, naming
them and offering a technique to call and return from these
procedures. i.e., Reuse the same code at different places in the
program without copying it.
26Presented By: Tekendra Nath Yogi
Contd…
• Procedural Programming:
– Combine returning sequences of statements
into one single place
– A procedure call is used to invoke the
procedure
– After the sequence is processed, flow of
control proceeds right after the position
where the call was made
27Presented By: Tekendra Nath Yogi
Contd…
• With the introduction of parameters as well as procedures of procedures ( sub-
procedures) programs can now be written more structured and error free
– For example, if a procedure is correct, every time it is used it produces correct results
• The main program is responsible to pass data to the individual calls, the data is
processed by the procedures and, once the program has finished, the resulting
data is presented
28Presented By: Tekendra Nath Yogi
Contd…
• Now we have a single program which is divided into small pieces
called procedures
• To enable usage of general procedures or groups of procedures
also in other programs, they must be separately available
• For that reason, modular programming allows grouping of
procedures into modules
29Presented By: Tekendra Nath Yogi
Contd…
• Structured Programming (Modular Programming) Paradigm:
– During the 1970s it became clear that even well-structured programs were
not enough for mastering the complexity involved in developing a large
program system
– It was also recognized that it was necessary to support the division of the
program into well-defined parts or modules, that could be developed and
tested independently of one another, so that several people could work
together within one large programming project
– Modular programming (subset of procedural programming)is thus
concerned with the subdivision of programs into manageable "chunks"
30Presented By: Tekendra Nath Yogi
Contd…
• With modular programming procedures of a common
functionality are grouped together into separate modules
• A program therefore no longer consists of only one single
part.
• It is now divided into several smaller parts which interact
through procedure calls and which form the whole
program
31Presented By: Tekendra Nath Yogi
Contd…
• Each module can have its own data. This allows each module to manage an
internal state which is modified by calls to procedures of this module
32Presented By: Tekendra Nath Yogi
Contd…
33Presented By: Tekendra Nath Yogi
CPS235: Introduction 33
Unstructured, procedural, modular programming
Unstructured programming.
The main program directly
operates on global data
Procedural programming.
The main program
coordinates calls to
procedures and hands over
appropriate data as parameters
Modular programming. The main
program coordinates calls to
procedures in separate modules
and hands over appropriate data
as parameters
Contd…
• Features of structured programming:
– Emphasis is given on algorithm rather than on data.
– Large programs are divided into smaller programs known
as functions and functions are grouped into modules.
– Most of the functions share global data.
– Data move openly around the system from function to
function.
34Presented By: Tekendra Nath Yogi
Contd…
• Advantages of structured programming: The
following are the major advantages of structured
programming.
– Reduced complexity
– Increased productivity
– portability
35Presented By: Tekendra Nath Yogi
Contd…
• Problems with structured programming: Some
problems with structured programming are:
– Complexity of managing large projects
– Data under-valued
– Relationship to real world
– New data types
36Presented By: Tekendra Nath Yogi
Contd…
• Complexity of managing large projects:
– As programs grow larger, even structured programming
approach begins to show signs of strain.
– No matter how well the structured programming approach is
implemented, the project becomes too complex, the schedule
slips, more programmers are needed, and costs skyrocket.
37Presented By: Tekendra Nath Yogi
Contd…
• Data Undervalued:
– Data is given second-class status in the organization of
procedural languages.
– A global data can be corrupted by functions. Since many
functions access the same global data, the way the data is
stored becomes critical.
38Presented By: Tekendra Nath Yogi
Contd…
• Relationship to the Real World:
– Procedural programs are often difficult to design
because their chief components – functions and data
structures – don’t model the real world very well.
39Presented By: Tekendra Nath Yogi
Contd…
• New Data Types:
– It is difficult to create new data types with procedural languages.
– Furthermore, most Procedural languages are not usually extensible
and hence procedural programs are more complex to write and
maintain.
40Presented By: Tekendra Nath Yogi
The problems faced in the structured programming approach are the
motivating factor in the invention of objected oriented approach.
Contd…
• Object Oriented Programming(OOP) Paradigm:
• In the OOP approach, data and the functions, which are supposed to have the
access to the data, are packed together into a single unit known as an object
• An objected-oriented program may thus consists of number of objects .
• Each Objects of the program is capable of receiving message, processing data ,
and sending messages to other objects thus, can be viewed as an independent
machine with a distinct role and responsibility.
41Presented By: Tekendra Nath Yogi
Characteristics(features) of object oriented languages:
• Different features of object oriented programming are:
– Objects
– Classes
– abstraction
– Encapsulation
– Inheritance
– Polymorphism
– Message passing
42Presented By: Tekendra Nath Yogi
Contd…
• Objects:
– Objects are the basic run- time entities in an object-oriented program.
– They may represent a person, place, table etc. They are identified by its
unique name.
– An object represents a particular instance of a class. There can be more
than one instance.
– Each object contains data and code to manipulate the data. So, they occupy
space in memory.
43Presented By: Tekendra Nath Yogi
B.sc CSIT  2nd semester C++ unit-1
B.sc CSIT  2nd semester C++ unit-1
Contd…
• Classes:
– Collection of objects is called class. It is a logical
entity. So, it does not occupy space.
– Classes are user defined data types and objects are
variables of class.
– Once a class has been defined we can create any
number of objects for that class
46Presented By: Tekendra Nath Yogi
B.sc CSIT  2nd semester C++ unit-1
Contd…
• Abstraction:
– Abstraction means the representation of the essential
features without providing the internal details and
complexities.
• For example: phone call, we don't know the internal
processing.
– In OOP, abstraction is achieved by the help of class,
where data and methods are combined to extract the
essential features only.
48Presented By: Tekendra Nath Yogi
Contd…
49Presented By: Tekendra Nath Yogi
Contd…
• Encapsulation:
– Encapsulation is the process of combining the data (called
fields or attributes) and functions (called methods or
behaviors) into a single framework called class.
– Encapsulation helps preventing the modification of data
from outside the class by properly assigning the access
privilege to the data inside the class.
– So the term data hiding is possible due to the concept of
encapsulation, since the data are hidden from the outside
world.
50Presented By: Tekendra Nath Yogi
B.sc CSIT  2nd semester C++ unit-1
Contd…
• Inheritance:
– Inheritance is the process of acquiring certain
attributes and behaviors from parents.
• For examples, cars, trucks, buses, and motorcycles inherit
all characteristics of vehicles.
52Presented By: Tekendra Nath Yogi
B.sc CSIT  2nd semester C++ unit-1
B.sc CSIT  2nd semester C++ unit-1
Contd…
– Object-oriented programming allows classes to inherit
commonly used data and functions from other classes.
– If we derive a class(called derived class) from another class
(called base class), some of the data and functions can be
inherited so that we can reuse the already written and tested
code in our program, simplifying our program.
55Presented By: Tekendra Nath Yogi
Contd…
• Polymorphism:
– The word polymorphism means having many forms.
– Real life example of polymorphism, a person at a same
time can have different characteristic. Like a man at a
same time is a father, a husband, a employee. So a same
person posses have different behavior in different
situations. This is called polymorphism.
56Presented By: Tekendra Nath Yogi
Contd…
• Polymorphism is considered as one of the important features of
Object Oriented Programming.
• In C++ polymorphism is mainly divided into two types:
– Compile time Polymorphism : This type of polymorphism is
achieved by:
• Function overloading or
• Operator overloading
– Runtime Polymorphism : This type of polymorphism is achieved by
Function Overriding.
57Presented By: Tekendra Nath Yogi
B.sc CSIT  2nd semester C++ unit-1
Contd…
• Dynamic Binding:
– Binding Refers to linking of a procedure call to the code
to be executed in response to the call.
– Dynamic binding means that the code associated with a
given procedure call in not known until the time of call at
run-time.
– It is also known as late binding.
59Presented By: Tekendra Nath Yogi
Contd…
• Message Passing:
– An object-oriented program consist of a set of objects that
communicate with each other by sending and receiving
message.
– Message for an object is a request for execution of a
procedure and therefore will invoke a function in the
receiving object that generates the desired result.
60Presented By: Tekendra Nath Yogi
B.sc CSIT  2nd semester C++ unit-1
Contd…
• Advantages of OOPs:
– Code recycle and reuse.
– Easy to partition the work in a project based on objects. So, Software
Complexity can be easily handled and managed.
– Message passing technique between objects for communication makes
interface description with external systems much more straightforward.
– Possible to map objects in a problem domain within a program.
– Data hiding is possible.
– Use of inheritance can eliminate redundant codes in a program.
62Presented By: Tekendra Nath Yogi
Contd…
• Disadvantages of OOPs:
– Compile and runtime overhead.
– Re-orientation of software developer to object-oriented thinking.
– Requires the mastery in software engineering and programming
methodology.
– Benefits only in long run while managing large software projects.
– The message passing between many object in a complex application
can be difficult to trace and debug.
63Presented By: Tekendra Nath Yogi
Contd…
Structured Programming Object Oriented Programming
Structured Programming is designed which
focuses on procedure and then data required for
that procedure.
Object Oriented Programming is designed which
focuses on data.
Structured Programming is also known as Modular
Programming and a subset of procedural
programming language.
Object Oriented Programming supports inheritance,
encapsulation, abstraction, polymorphism, etc.
In Structured Programming, Programs are divided
into small self contained functions.
In Object Oriented Programming, Programs are
divided into small entities called objects.
Structured Programming is less secure as there is
no way of data hiding.
Object Oriented Programming is more secure as
having data hiding feature.
Structured Programming can
solve moderately complex programs.
Object Oriented Programming can solve
any complex programs.
Structured Programming provides less reusability,
more function dependency.
Object Oriented Programming provides more
reusability, less function dependency.
Less abstraction and less flexibility. More abstraction and more flexibility.
64Presented By: Tekendra Nath Yogi
Object-Based Programming
• The Fundamental idea behind object-based programming is the concept
of object ( the idea of encapsulating data and operations) where one or
more of the following restrictions apply:
– There is no implicit inheritance
– There is no polymorphism
– Only a very reduced subset of the available values are objects(Typically the
GUI components)
– E.g., Visual basic(VB)
65Presented By: Tekendra Nath Yogi
Homework
1. Explain characteristics and limitations of procedure-oriented programming?
How OOP overcome those limitations.
2. What is objected oriented programming? Explain objects, class,
encapsulation, data hiding, inheritance, and polymorphism.
3. Differentiate between structured programming and OOP
4. Compare and contrast between object oriented and object-based
programming languages with examples.
5. “Inheritance and polymorphism is important features of OOPs” explain and
justify this statement.
66Presented By: Tekendra Nath Yogi
Recommended Reading
• Robert Lafore, Chapter1: The Big Picture
CPS235: Introduction 67
Thank You !
68Presented By: Tekendra Nath Yogi

More Related Content

PPTX
B.sc CSIT 2nd semester C++ Unit6
PPTX
B.sc CSIT 2nd semester C++ Unit2
PPT
C by balaguruswami - e.balagurusamy
PDF
OOPS_Unit_1
PPTX
Control structures in c++
PPTX
PPT
Control structure C++
B.sc CSIT 2nd semester C++ Unit6
B.sc CSIT 2nd semester C++ Unit2
C by balaguruswami - e.balagurusamy
OOPS_Unit_1
Control structures in c++
Control structure C++

What's hot (20)

PPT
friend function(c++)
PPT
Unified Modeling Language
PPT
Input and output in C++
PDF
Introduction to c++ ppt
PDF
Introduction to c++ ppt 1
PPTX
Function C programming
ODP
Evolutionary process models se.ppt
PDF
Object oriented programming c++
PDF
Software Engineering : Requirement Analysis & Specification
PPTX
Built in function
PPTX
Intro to c++
PDF
Friend function in c++
PPSX
Files in c++
PPTX
Object oriented programming 6 oop with c++
PPTX
Conditional statement c++
PPTX
Event Handling in Java
PPTX
Oop c++class(final).ppt
PPTX
Storage classes in c++
PPTX
Lecture01 object oriented-programming
friend function(c++)
Unified Modeling Language
Input and output in C++
Introduction to c++ ppt
Introduction to c++ ppt 1
Function C programming
Evolutionary process models se.ppt
Object oriented programming c++
Software Engineering : Requirement Analysis & Specification
Built in function
Intro to c++
Friend function in c++
Files in c++
Object oriented programming 6 oop with c++
Conditional statement c++
Event Handling in Java
Oop c++class(final).ppt
Storage classes in c++
Lecture01 object oriented-programming
Ad

Similar to B.sc CSIT 2nd semester C++ unit-1 (20)

PPTX
[OOP - Lec 01] Introduction to OOP
PPTX
Unit - I Intro. to OOP Concepts and Control Structure -OOP and CG (2024 Patte...
PPTX
OOP CHAPTER object oreinted programming using c++
PDF
Lecture 1 (bce-7)
PPTX
SE-IT JAVA LAB OOP CONCEPT
PPT
Chapter12.ppt
PPT
Object-Oriented Design CS177 Python Programming
PPT
Chapter12 python object oriented concepts.ppt
PPTX
2R-3KS03-OOP_UNIT-I (Part-A)_2023-24.pptx
PPT
16613874-Object-Oriented-Programming-Presentation.ppt
PPT
01 introduction to cpp
PPTX
chapter _3.pptx Programming Language in DSS
DOC
6th sem
PPT
01-introductionto Object ooriented Programming in JAVA CS.ppt
PPT
01-introduction OOPS concepts in C++ JAVA
PPT
Software Design – Overview – Characteristics – Cohesion & Coupling – Layered ...
PPTX
Expection Setting - 1st ppt. pptx
PPT
Oop(object oriented programming)
PPT
Lecture 1 Overview of Computer Programming.ppt
PPTX
DE PPT.pptx
[OOP - Lec 01] Introduction to OOP
Unit - I Intro. to OOP Concepts and Control Structure -OOP and CG (2024 Patte...
OOP CHAPTER object oreinted programming using c++
Lecture 1 (bce-7)
SE-IT JAVA LAB OOP CONCEPT
Chapter12.ppt
Object-Oriented Design CS177 Python Programming
Chapter12 python object oriented concepts.ppt
2R-3KS03-OOP_UNIT-I (Part-A)_2023-24.pptx
16613874-Object-Oriented-Programming-Presentation.ppt
01 introduction to cpp
chapter _3.pptx Programming Language in DSS
6th sem
01-introductionto Object ooriented Programming in JAVA CS.ppt
01-introduction OOPS concepts in C++ JAVA
Software Design – Overview – Characteristics – Cohesion & Coupling – Layered ...
Expection Setting - 1st ppt. pptx
Oop(object oriented programming)
Lecture 1 Overview of Computer Programming.ppt
DE PPT.pptx
Ad

More from Tekendra Nath Yogi (20)

PDF
Unit9:Expert System
PDF
Unit7: Production System
PDF
Unit8: Uncertainty in AI
PDF
Unit5: Learning
PDF
Unit4: Knowledge Representation
PDF
Unit3:Informed and Uninformed search
PDF
Unit2: Agents and Environment
PDF
Unit1: Introduction to AI
PDF
Unit 6: Application of AI
PPTX
PDF
BIM Data Mining Unit5 by Tekendra Nath Yogi
PDF
BIM Data Mining Unit4 by Tekendra Nath Yogi
PDF
BIM Data Mining Unit3 by Tekendra Nath Yogi
PDF
BIM Data Mining Unit2 by Tekendra Nath Yogi
PDF
BIM Data Mining Unit1 by Tekendra Nath Yogi
PPTX
B. SC CSIT Computer Graphics Unit 5 By Tekendra Nath Yogi
Unit9:Expert System
Unit7: Production System
Unit8: Uncertainty in AI
Unit5: Learning
Unit4: Knowledge Representation
Unit3:Informed and Uninformed search
Unit2: Agents and Environment
Unit1: Introduction to AI
Unit 6: Application of AI
BIM Data Mining Unit5 by Tekendra Nath Yogi
BIM Data Mining Unit4 by Tekendra Nath Yogi
BIM Data Mining Unit3 by Tekendra Nath Yogi
BIM Data Mining Unit2 by Tekendra Nath Yogi
BIM Data Mining Unit1 by Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 5 By Tekendra Nath Yogi

Recently uploaded (20)

PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Computing-Curriculum for Schools in Ghana
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
Classroom Observation Tools for Teachers
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Pharma ospi slides which help in ospi learning
Supply Chain Operations Speaking Notes -ICLT Program
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
STATICS OF THE RIGID BODIES Hibbelers.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
GDM (1) (1).pptx small presentation for students
Computing-Curriculum for Schools in Ghana
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Microbial diseases, their pathogenesis and prophylaxis
2.FourierTransform-ShortQuestionswithAnswers.pdf
Weekly quiz Compilation Jan -July 25.pdf
Classroom Observation Tools for Teachers
human mycosis Human fungal infections are called human mycosis..pptx
Pharma ospi slides which help in ospi learning

B.sc CSIT 2nd semester C++ unit-1

  • 1. College of applied Business(CAB) And Technology Course Name Object Oriented Programming (CSC-161) Faculty Name Mr. Tekendra Nath Yogi Tekendranath@gmail.com
  • 2. Course Title: Design and Analysis of Algorithms • Course no: CSC- 161 Full Marks: 60+20+ 20 • Credit hours: 3 Pass Marks: 24+ 8 +8 • Nature of course: Theory + Lab • Course Description: – The course covers the basic concepts of object oriented programming using C++ programming language. • Course Objectives: – The main objective of this course is to understand object oriented programming and advanced C++ concepts such as composition of objects, operator overloads, inheritance and polymorphism, file I/O, exception handling and templates. 2Presented By: Tekendra Nath Yogi
  • 3. Course Contents: • Unit 1: Introduction to Object Oriented Programming (3 Hrs.) – Overview of structured programming approach. – Problems with structured programming. – Object oriented programming approach – Characteristics of object oriented languages • Objects • Classes • Data abstraction and encapsulation • Polymorphism • Overloading • inheritance 3Presented By: Tekendra Nath Yogi
  • 4. Contd… • Unit 2: Basics of C++ programming (5 Hrs.) – C++ Program Structure – Character Set and Tokens(Keywords, identifiers, constants, operators, special symbols) – Data Type ( Basic types, derived types, and user defined types) – Type Conversion( Explicit conversion(Type cast operator), Implicit conversion) – Preprocessor Directives( include and define directives) 4Presented By: Tekendra Nath Yogi
  • 5. Contd… • Namespace • Input/Output Streams (Cin and Cout) and Manipulators ( setw and endl) • Dynamic Memory Allocation with new and delete • Control Statements(abstract review of decision making and branching, decision making and looping). • Functions: Function Overloading (different number of arguments, different types of argument) • Inline Functions • Default Argument • Pass by Reference • Return by Reference 5Presented By: Tekendra Nath Yogi
  • 6. Contd… • Scope (local, file, and class) and Storage Class. • Pointers: Pointer variables declaration & initialization, Operators in pointers(Address-of and value-at- the- address) • Pointers and Arrays, • Pointer and Function(Passing simple variables, passing arrays). 6Presented By: Tekendra Nath Yogi
  • 7. Contd… • Unit 3: Classes & Objects (8 Hrs.) – A Simple Class and Object (class definition: data member and function member) – Accessing members of class – Initialization of class objects: (Constructor, Destructor) – Default Constructor, Parameterized Constructor, Copy Constructor, The Default Copy Constructor, – destructor 7Presented By: Tekendra Nath Yogi
  • 8. Contd… – Objects as Function Arguments, – Returning Objects from Functions, – Structures and Classes, – Memory allocation for Objects, – Static members, – Member functions defined outside the class (Using scope resolution operator). 8Presented By: Tekendra Nath Yogi
  • 9. Contd… • Unit 4: Operator Overloading (7 Hrs.) – Fundamental of operator overloading, Restriction on operator overloading, Operator functions as a class members, – Overloading unary and binary operator, – Data Conversion (basic to basic, basic to user-defined, user-defined to basic, user-defined to user-defined) 9Presented By: Tekendra Nath Yogi
  • 10. Contd… • Unit 5: Inheritance (7 Hrs.) – Introduction to inheritance, Derived Class and Base Class, – Access Specifiers (private, protected, and public), – Types of inheritance(simple, multiple, hierarchical, multi-level, hybrid) – Public and Private Inheritance, – Constructor and Destructor in derived classes, – Aggregation (class with in class) 10Presented By: Tekendra Nath Yogi
  • 11. Contd… • Unit 6: Virtual Function, Polymorphism, and miscellaneous C++ Features (5 Hrs.) – Concept of Virtual functions (difference between normal member function accessed with pointers and virtual member function accessed with pointer) – Late Binding, Abstract class and pure virtual functions – Virtual Destructors, Virtual base class – Friend function(friend class) and Static function, – Assignment and copy initialization, Copy constructor, – This pointer, – Concrete classes(vs. abstract class), – Polymorphism and its roles. 11Presented By: Tekendra Nath Yogi
  • 12. Contd… • Unit 7: Function Templates and Exception Handling (4 Hrs.) – Function templates – Function templates with multiple arguments – Class templates – templates and inheritance – Exceptional Handling (Try, throw and catch) – Use of exceptional handling. 12Presented By: Tekendra Nath Yogi
  • 13. Contd… • Unit 8: File handling (6 Hrs.) – Stream Class Hierarchy for Console Input /Output, – Unformatted Input /Output, – Formatted Input /Output with ios Member functions, – Formatting with Manipulators, – Stream Operator Overloading, – File Input/output with Streams, 13Presented By: Tekendra Nath Yogi
  • 14. Contd… – Opening and Closing files (open() and close() member function) – Read/Write from File ( put() and get(), read(), and write(), member functions) – File Access Pointers and their Manipulators (seeks(), seekp(), tellg(), tellP(), offset, and etc..) – Sequential and Random Access to File, – Testing Errors during File Operations (eof(), fail(),bad(), good()) 14Presented By: Tekendra Nath Yogi
  • 15. Laboratory Works • Students should be able to implement the concepts of Object Oriented Programming using C++ language. 15Presented By: Tekendra Nath Yogi
  • 16. Text Books • Robert Lafore, Object Oriented Programming in C++, Fourth Edition, SAMS publications. • Herbert Schildt, C++ The Complete Reference, Fourth Edition, Tata McGraw Hill Publication. 16Presented By: Tekendra Nath Yogi
  • 17. Reference Books • Deitel and Deitel, C++ How to Program, Third Edition, Pearson Publication. • Joyce Farrell, Object-oriented programming using C++, Fourth Edition, Cengage Learning. 17Presented By: Tekendra Nath Yogi
  • 18. Model Question F.M.: 60 P.M.: 24 Section A(Long Answer questions): Attempt any two questions [2*10= 20] – 1. – 2. – 3. • Section B(Short Answer questions): Attempt any eight questions [8*5=40] – 4. – 5. – 6. – 7. – 8. – 9. – 10. – 11. – 12. 18Presented By: Tekendra Nath Yogi
  • 19. Unit1: Introduction to objected oriented programming • Programming: – The art and science of creating programs – Art: application of human creative skill and imagination. – Science: systematic study through observation and experiment. • So, to be a good programmer you should do a lot of experiment and observation of programs by using your own creative skill and imagination. 19Presented By: Tekendra Nath Yogi
  • 20. Contd… • Program: – Program outlines exactly the steps needed to perform a certain task. – E.g., Add two numbers 20Presented By: Tekendra Nath Yogi
  • 21. Contd… • Programming language: – A programming language is a tool used by programmers for instructing a computer or computing device to perform specific tasks. 21Presented By: Tekendra Nath Yogi
  • 22. Contd… • Classification Of Programming Languages: – Machine Language: • use 0 and 1 to express the instructions to perform a certain task. – Assembly Language: • This language uses symbols to express the instructions to perform the certain task. – High-level language: • This language uses mostly high level language like statement to express the instructions to perform a certain task. 22Presented By: Tekendra Nath Yogi
  • 23. Contd.. • The Top Programming Languages? – IEEE Ranking of programming language: 23Presented By: Tekendra Nath Yogi
  • 24. Programming Paradigms • Program organizing principles are called programming paradigms. • Following are the five types of programming paradigm: – Unstructured programming – Procedural programming – Structured programming – Object-oriented programming – Object-based programming 24Presented By: Tekendra Nath Yogi
  • 25. Contd… • Unstructured Programming paradigm: – A Technique for organizing and coding computer programs in which programmers put all their code in one program. 25Presented By: Tekendra Nath Yogi
  • 26. Contd… • This programming technique provides tremendous disadvantages (duplicacy and redundancy of code, code maintenance problem, readability and many more ) once the program gets sufficiently large • For example, if the same statement sequence is needed at different locations within the program, the sequence must be copied. • This has lead to the idea of extracting these sequences, naming them and offering a technique to call and return from these procedures. i.e., Reuse the same code at different places in the program without copying it. 26Presented By: Tekendra Nath Yogi
  • 27. Contd… • Procedural Programming: – Combine returning sequences of statements into one single place – A procedure call is used to invoke the procedure – After the sequence is processed, flow of control proceeds right after the position where the call was made 27Presented By: Tekendra Nath Yogi
  • 28. Contd… • With the introduction of parameters as well as procedures of procedures ( sub- procedures) programs can now be written more structured and error free – For example, if a procedure is correct, every time it is used it produces correct results • The main program is responsible to pass data to the individual calls, the data is processed by the procedures and, once the program has finished, the resulting data is presented 28Presented By: Tekendra Nath Yogi
  • 29. Contd… • Now we have a single program which is divided into small pieces called procedures • To enable usage of general procedures or groups of procedures also in other programs, they must be separately available • For that reason, modular programming allows grouping of procedures into modules 29Presented By: Tekendra Nath Yogi
  • 30. Contd… • Structured Programming (Modular Programming) Paradigm: – During the 1970s it became clear that even well-structured programs were not enough for mastering the complexity involved in developing a large program system – It was also recognized that it was necessary to support the division of the program into well-defined parts or modules, that could be developed and tested independently of one another, so that several people could work together within one large programming project – Modular programming (subset of procedural programming)is thus concerned with the subdivision of programs into manageable "chunks" 30Presented By: Tekendra Nath Yogi
  • 31. Contd… • With modular programming procedures of a common functionality are grouped together into separate modules • A program therefore no longer consists of only one single part. • It is now divided into several smaller parts which interact through procedure calls and which form the whole program 31Presented By: Tekendra Nath Yogi
  • 32. Contd… • Each module can have its own data. This allows each module to manage an internal state which is modified by calls to procedures of this module 32Presented By: Tekendra Nath Yogi
  • 33. Contd… 33Presented By: Tekendra Nath Yogi CPS235: Introduction 33 Unstructured, procedural, modular programming Unstructured programming. The main program directly operates on global data Procedural programming. The main program coordinates calls to procedures and hands over appropriate data as parameters Modular programming. The main program coordinates calls to procedures in separate modules and hands over appropriate data as parameters
  • 34. Contd… • Features of structured programming: – Emphasis is given on algorithm rather than on data. – Large programs are divided into smaller programs known as functions and functions are grouped into modules. – Most of the functions share global data. – Data move openly around the system from function to function. 34Presented By: Tekendra Nath Yogi
  • 35. Contd… • Advantages of structured programming: The following are the major advantages of structured programming. – Reduced complexity – Increased productivity – portability 35Presented By: Tekendra Nath Yogi
  • 36. Contd… • Problems with structured programming: Some problems with structured programming are: – Complexity of managing large projects – Data under-valued – Relationship to real world – New data types 36Presented By: Tekendra Nath Yogi
  • 37. Contd… • Complexity of managing large projects: – As programs grow larger, even structured programming approach begins to show signs of strain. – No matter how well the structured programming approach is implemented, the project becomes too complex, the schedule slips, more programmers are needed, and costs skyrocket. 37Presented By: Tekendra Nath Yogi
  • 38. Contd… • Data Undervalued: – Data is given second-class status in the organization of procedural languages. – A global data can be corrupted by functions. Since many functions access the same global data, the way the data is stored becomes critical. 38Presented By: Tekendra Nath Yogi
  • 39. Contd… • Relationship to the Real World: – Procedural programs are often difficult to design because their chief components – functions and data structures – don’t model the real world very well. 39Presented By: Tekendra Nath Yogi
  • 40. Contd… • New Data Types: – It is difficult to create new data types with procedural languages. – Furthermore, most Procedural languages are not usually extensible and hence procedural programs are more complex to write and maintain. 40Presented By: Tekendra Nath Yogi The problems faced in the structured programming approach are the motivating factor in the invention of objected oriented approach.
  • 41. Contd… • Object Oriented Programming(OOP) Paradigm: • In the OOP approach, data and the functions, which are supposed to have the access to the data, are packed together into a single unit known as an object • An objected-oriented program may thus consists of number of objects . • Each Objects of the program is capable of receiving message, processing data , and sending messages to other objects thus, can be viewed as an independent machine with a distinct role and responsibility. 41Presented By: Tekendra Nath Yogi
  • 42. Characteristics(features) of object oriented languages: • Different features of object oriented programming are: – Objects – Classes – abstraction – Encapsulation – Inheritance – Polymorphism – Message passing 42Presented By: Tekendra Nath Yogi
  • 43. Contd… • Objects: – Objects are the basic run- time entities in an object-oriented program. – They may represent a person, place, table etc. They are identified by its unique name. – An object represents a particular instance of a class. There can be more than one instance. – Each object contains data and code to manipulate the data. So, they occupy space in memory. 43Presented By: Tekendra Nath Yogi
  • 46. Contd… • Classes: – Collection of objects is called class. It is a logical entity. So, it does not occupy space. – Classes are user defined data types and objects are variables of class. – Once a class has been defined we can create any number of objects for that class 46Presented By: Tekendra Nath Yogi
  • 48. Contd… • Abstraction: – Abstraction means the representation of the essential features without providing the internal details and complexities. • For example: phone call, we don't know the internal processing. – In OOP, abstraction is achieved by the help of class, where data and methods are combined to extract the essential features only. 48Presented By: Tekendra Nath Yogi
  • 50. Contd… • Encapsulation: – Encapsulation is the process of combining the data (called fields or attributes) and functions (called methods or behaviors) into a single framework called class. – Encapsulation helps preventing the modification of data from outside the class by properly assigning the access privilege to the data inside the class. – So the term data hiding is possible due to the concept of encapsulation, since the data are hidden from the outside world. 50Presented By: Tekendra Nath Yogi
  • 52. Contd… • Inheritance: – Inheritance is the process of acquiring certain attributes and behaviors from parents. • For examples, cars, trucks, buses, and motorcycles inherit all characteristics of vehicles. 52Presented By: Tekendra Nath Yogi
  • 55. Contd… – Object-oriented programming allows classes to inherit commonly used data and functions from other classes. – If we derive a class(called derived class) from another class (called base class), some of the data and functions can be inherited so that we can reuse the already written and tested code in our program, simplifying our program. 55Presented By: Tekendra Nath Yogi
  • 56. Contd… • Polymorphism: – The word polymorphism means having many forms. – Real life example of polymorphism, a person at a same time can have different characteristic. Like a man at a same time is a father, a husband, a employee. So a same person posses have different behavior in different situations. This is called polymorphism. 56Presented By: Tekendra Nath Yogi
  • 57. Contd… • Polymorphism is considered as one of the important features of Object Oriented Programming. • In C++ polymorphism is mainly divided into two types: – Compile time Polymorphism : This type of polymorphism is achieved by: • Function overloading or • Operator overloading – Runtime Polymorphism : This type of polymorphism is achieved by Function Overriding. 57Presented By: Tekendra Nath Yogi
  • 59. Contd… • Dynamic Binding: – Binding Refers to linking of a procedure call to the code to be executed in response to the call. – Dynamic binding means that the code associated with a given procedure call in not known until the time of call at run-time. – It is also known as late binding. 59Presented By: Tekendra Nath Yogi
  • 60. Contd… • Message Passing: – An object-oriented program consist of a set of objects that communicate with each other by sending and receiving message. – Message for an object is a request for execution of a procedure and therefore will invoke a function in the receiving object that generates the desired result. 60Presented By: Tekendra Nath Yogi
  • 62. Contd… • Advantages of OOPs: – Code recycle and reuse. – Easy to partition the work in a project based on objects. So, Software Complexity can be easily handled and managed. – Message passing technique between objects for communication makes interface description with external systems much more straightforward. – Possible to map objects in a problem domain within a program. – Data hiding is possible. – Use of inheritance can eliminate redundant codes in a program. 62Presented By: Tekendra Nath Yogi
  • 63. Contd… • Disadvantages of OOPs: – Compile and runtime overhead. – Re-orientation of software developer to object-oriented thinking. – Requires the mastery in software engineering and programming methodology. – Benefits only in long run while managing large software projects. – The message passing between many object in a complex application can be difficult to trace and debug. 63Presented By: Tekendra Nath Yogi
  • 64. Contd… Structured Programming Object Oriented Programming Structured Programming is designed which focuses on procedure and then data required for that procedure. Object Oriented Programming is designed which focuses on data. Structured Programming is also known as Modular Programming and a subset of procedural programming language. Object Oriented Programming supports inheritance, encapsulation, abstraction, polymorphism, etc. In Structured Programming, Programs are divided into small self contained functions. In Object Oriented Programming, Programs are divided into small entities called objects. Structured Programming is less secure as there is no way of data hiding. Object Oriented Programming is more secure as having data hiding feature. Structured Programming can solve moderately complex programs. Object Oriented Programming can solve any complex programs. Structured Programming provides less reusability, more function dependency. Object Oriented Programming provides more reusability, less function dependency. Less abstraction and less flexibility. More abstraction and more flexibility. 64Presented By: Tekendra Nath Yogi
  • 65. Object-Based Programming • The Fundamental idea behind object-based programming is the concept of object ( the idea of encapsulating data and operations) where one or more of the following restrictions apply: – There is no implicit inheritance – There is no polymorphism – Only a very reduced subset of the available values are objects(Typically the GUI components) – E.g., Visual basic(VB) 65Presented By: Tekendra Nath Yogi
  • 66. Homework 1. Explain characteristics and limitations of procedure-oriented programming? How OOP overcome those limitations. 2. What is objected oriented programming? Explain objects, class, encapsulation, data hiding, inheritance, and polymorphism. 3. Differentiate between structured programming and OOP 4. Compare and contrast between object oriented and object-based programming languages with examples. 5. “Inheritance and polymorphism is important features of OOPs” explain and justify this statement. 66Presented By: Tekendra Nath Yogi
  • 67. Recommended Reading • Robert Lafore, Chapter1: The Big Picture CPS235: Introduction 67
  • 68. Thank You ! 68Presented By: Tekendra Nath Yogi