Unit 1
Unit 1
Shubhangi S. Shambharkar
Vision & Mission
Vision of the Department
• To be a well-known center for pursuing computer
education through innovative pedagogy, value-
based education and industry collaboration.
Mission of the Department
• To establish learning ambience for ushering in
computer engineering professionals in core and
multidisciplinary arena by developing problem-
solving skills through emerging technologies.
Program Outcome
• PO 1 – Engineering knowledge
• PO 2 – Problem analysis
• PO 3 -Design/development of solutions
• PO 4 – Conduct investigations of complex problems
• PO 5 – Modern tool usage
• PO 6 – The engineer and society
• PO 7 – Ethics
• PO 8 – Individual and team work
• PO 9 – Communication
• PO 10 – Project management and finance
• PO 11 – Life-long learning
Scheme
Course Outcomes
• Upon successful completion of the course the
students will be able to
• 1. Understand the concept of object-oriented
programming and modelling
• 2. Apply the knowledge of object-oriented
programming to solve the given problem
• 3. Analyze the problem to provide the object
oriented solution using advanced
programming concepts.
Syllabus
Unit I: 6 Hrs.
Introduction to OOP ,History of OOP, structured and procedural programming, switching from
conventional to OO programming, Basic concepts of OOP, benefits and applications.
Unit II: 7 Hrs.
Programming with OOP Classes, objects, access specifiers, constructors, destructors, token
expressions and control structures functions: inline, friend.
Unit III: 7 Hrs.
Inheritance Types of inheritance: single, multiple, multilevel, hierarchical, hybrid, virtual base class,
abstract base class
Unit IV: 7 Hrs.
Polymorphism Introduction to polymorphism, virtual function, pure virtual function, pointers,
function and operator overloading
Unit V: 7 Hrs.
Exception and File Handling Throw and catch mechanism, rethrowing exception, specifying
exception, working with Files
6 Hrs.
Unit VI: Templates and STL ,Class template, function template, overloading template
function, non-type template organization, STL, components and types of STL:
• Textbooks:
• 1. Object Oriented Programming with C++, 5th edition , Bal
Gurusamy, McGraw Hill Publications.
• 2. Object Oriented Programming in C++ , 3rd edition ,
Lafore,R , Sams Publication
• Reference Books:
• 1. The C++ Programming Language, 6th edition ,
Stroustrup.B , Pearson Education
• 2. C++ The Complete Reference , 6th edition , Schildt, H ,
McGraw Hill Publications
• return 0;
• }
• The #include is a preprocessor directive tells the
compiler to include the content of a file in the
source code. For
example, #include<iostream> tells the compiler
to include the input-output library which contains
all C++’s input/output library functions.
• This is used to import the entity of
the stdnamespace into the current namespace of
the program. It is basically the space where all
the inbuilt features of C++ are declared. For
example, std::cout.
Standard Output Stream – cout
• 6) Rich Library
• C++ provides a lot of inbuilt functions that make the development
fast. Following are the libraries used in C++ programming are:
• <iostream>
• <cmath>
• <cstdlib>
• <fstream>
• 7) Memory Management
• C++ provides very efficient management techniques. The
various memory management operators help save the
memory and improve the program's efficiency. These
operators allocate and deallocate memory at run time.
Some common memory management operators available
C++ are new, delete etc.
• 8) Quicker Compilation
• C++ programs tend to be compact and run quickly. Hence
the compilation and execution time of the C++ language is
fast.
• 9) Pointer
• C++ provides the feature of pointers. We can use pointers
for memory, structures, functions, array, etc. We can
directly interact with the memory by using the pointers.
• 10) Recursion
• In C++, we can call the function within the
function. It provides code reusability for every
function.
• 11) Extensible
• C++ programs can easily be extended as it is very
easy to add new features into the existing
program.
• 12) Object-Oriented
• In C++, object-oriented concepts like data hiding,
encapsulation, and data abstraction can easily be
implemented using keyword class, private, public,
and protected access specifiers. Object-oriented
makes development and maintenance easier
• 13) Compiler based
• C++ is a compiler-based programming language, which
means no C++ program can be executed without
compilation. C++ compiler is easily available, and it requires
very little space for storage. First, we need to compile our
program using a compiler, and then we can execute our
program.
• 14) Reusability
• With the use of inheritance of functions programs written
in C++ can be reused in any other program of C++. You can
save program parts into library files and invoke them in
your next programming projects simply by including the
library files. New programs can be developed in lesser time
as the existing code can be reused. It is also possible to
define several functions with same name that perform
different task. For Example: abs () is used to calculate the
absolute value of integer, float and long integer.
• 15) Errors are easily detected
• It is easier to maintain a C++ programs as errors can be
easily located and rectified. It also provides a feature
called exception handling to support error handling in
your program.
• 16) Power and Flexibility
• C++ is a powerful and flexible language because of
most of the powerful flexible and modern UNIX
operating system is written in C++. Many compilers and
interpreters for other languages such as FORTRAN,
PERL, Python, PASCAL, BASIC, LISP, etc., have been
written in C++. C++ programs have been used for
solving physics and engineering problems and even for
animated special effects for movies.
• 17) Strongly typed language
• The list of arguments of every function call is typed checked during
compilation. If there is a type mismatch between actual and formal
arguments, implicit conversion is applied if possible. A compile-time
occurs if an implicit conversion is not possible or if the number of
arguments is incorrect.
• 20) Clarity
• The keywords and library functions used in C++ resemble common
English words
No. C C++
1) C follows the procedural style C++ is multi-paradigm. It supports both procedural and
programming. object oriented.
2) Data is less secured in C. In C++, you can use modifiers for class members to
make it inaccessible for outside users.
3) C follows the top-down approach. C++ follows the bottom-up approach.
5) In C, you can't use functions in structure. In C++, you can use functions in structure.
7) In C, scanf() and printf() are mainly used for C++ mainly uses stream cin and cout to perform input
input/output. and output operations.
8) Operator overloading is not possible in C. Operator overloading is possible in C++.
9) C programs are divided into procedures C++ programs are divided into functions and classes.
and modules
10) C does not provide the feature of C++ supports the feature of namespace.
namespace.
11) Exception handling is not easy in C. It has to C++ provides exception handling using Try and Catch
perform using other functions. block.
12) C does not support the inheritance. C++ supports inheritance.
Object-oriented programming
• As the name suggests uses objects in programming.
• Object-oriented programming aims to implement real-world entities like
inheritance, hiding, polymorphism, etc. in programming.
• The main aim of OOP is to bind together the data and the functions that
operate on them so that no other part of the code can access this data
except that function.
• There are some basic concepts that act as the building blocks of OOPs i.e.
• Class
• Object
• Encapsulation
• Abstraction
• Polymorphism
• Inheritance
• Dynamic Binding
• Message Passing
Characteristics of an Object-Oriented
Programming Language
Important features of Object Oriented
Programming
The important features of Object
Oriented programming are:
• Abstraction
• Polymorphism
• Inheritance
• Encapsulation
};
Multiple Class Inheritance
• Consider the following classes
class A { ......}; • All the public and protected
parts of class A, become
class B {......}; private members / parts of the
derived class C.
class C: private A, public B• All the public parts of class B,
{ become public members /
parts of the derived class C.
. • All the protected parts of class
B, become protected
. members / parts of the
derived class C.
.
• No private member of class A
}; and class B can be accessed by
class C.
Ways of Deriving a Class
Polymorphism
• Polymorphism means ‘one name multiple
forms’.
• Polymorphism implementation in C++ can be
shown as in figure.
structured and procedural
programming
• 1. Structured Programming :
Structured Programming, as name suggests, is a technique that is
considered as precursor to OOP and usually consists of well-structured
and separated modules. In this programming, user can create its own
user-defined functions as well as this methodology tries to resolve issues
that are associated with unconditional transfers to allow programmers
follow logic of programs. It also requires more discipline at the design and
logical structuring stage.
• Example : Pascal, ALGOL, C, Modula-2, etc.
• 2. Object-Oriented Programming :
Object-Oriented Programming, as name suggests, is a different approach
to programming that brings together data and functions that execute on
them. It basically supports encapsulation, abstraction, inheritance,
polymorphism, etc. It also includes data hiding feature therefore it is more
secure. This model is based on real life entities that focuses on by whom
task is to be done rather than focusing on what to do.
• Example : JAVA, C#, C++, etc.
Structured Programming Object-Oriented Programming
It is a subset of procedural programming. It relies on concept of objects that contain data and code.
Programs are divided into small programs or functions. Programs are divided into objects or entities.
It is all about facilitating creation of programs with It is all about creating objects that usually contain both
readable code and reusable components. functions and data.
Its main aim is to improve and increase quality, clarity, and Its main aim is to improve and increase both quality and
development time of computer program. productivity of system analysis and design.
In this, methods are written globally and code lines are In this, method works dynamically, make calls as per need
processed one by one i.e., Run sequentially. of code for certain time.
It provides less flexibility and abstraction as compared to It provides more flexibility and abstraction as compared to
object-oriented programming. structured programming.
It is more difficult to modify structured program and reuse It is less difficult to modify object-oriented programs and
code as compared to object-oriented programs. reuse code as compared to structured programs.