This document outlines the course details for an Object Oriented Programming course using C++. It includes:
- The course name, number, credit hours, and description which focuses on basic OOP concepts using C++.
- An overview of the course contents which covers 8 units ranging from introductions to OOP and C++ to more advanced topics like inheritance, polymorphism, templates and file handling.
- Details of textbook and reference materials, evaluation criteria with sample questions, and an outline of the expected laboratory works for students to implement OOP concepts in C++.
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
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
44.
45.
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
47.
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
51.
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
53.
54.
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
58.
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
61.
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