0% found this document useful (0 votes)
88 views

C++ Unit 1

This document provides an overview of the key concepts to be covered in an Object Oriented Programming course using C++. The course will cover introduction to C++, object oriented programming concepts like classes, objects, encapsulation, inheritance and polymorphism. It will also discuss input/output operations, control structures, loops and functions in C++. Real-world applications of C++ include operating systems, browsers, games and databases. C++ allows both low-level systems programming and building large applications.

Uploaded by

Vanitha Rams
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views

C++ Unit 1

This document provides an overview of the key concepts to be covered in an Object Oriented Programming course using C++. The course will cover introduction to C++, object oriented programming concepts like classes, objects, encapsulation, inheritance and polymorphism. It will also discuss input/output operations, control structures, loops and functions in C++. Real-world applications of C++ include operating systems, browsers, games and databases. C++ allows both low-level systems programming and building large applications.

Uploaded by

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

E – Content

Subject: Object Oriented Programming Concepts Using C++


Subject Code: SU22A
Department: Computer Application
Shift: I
Class: I BCA
Semester: II
Prepared By: Ms.T.Reshma Banu

1
SU22A
Object Oriented Programming
Concepts Using C++
UNIT: I

2
Syllabus
Unit 1:
• Introduction to C++

• Key Concepts of Object Oriented programming


•Advantages - Object Oriented Languages
• I/O in C++ - I/O declarations
• Control Structures: Decision Making and Statements
• If, else, jump, goto, break, continue, Switch case
statements
• Loops in C++: for, while, do – functions in C++
• inline functions – Function Overloading

3
SU22A – Object Oriented Programming Concept Using C++
Introduction to C++
• C++ is a cross-platform language that can be used to create high-
performance applications.

• C++ is a general-purpose programming language that was


developed as an enhancement of the C language to include object-
oriented paradigm.

• Created by Bjarne Stroustrup in 1983 at Bell Labs

• C++ is a middle-level language rendering it the advantage of


programming low-level (drivers, kernels) and even higher-level
applications (games, GUI, desktop apps etc.).

• The basic syntax and code structure of both C and C++ are the
same. 

4
SU22A – Object Oriented Programming Concept Using C++
TM

FEATURES OF C++
• Simple: It is a simple language in the sense that programs can be
broken down into logical units and parts, has a rich library support and
a variety of data-types.

• Machine Independent but Platform Dependent: A C++ executable is


not platform-independent (compiled programs on Linux won’t run on
Windows), however they are machine independent.

• Rich library support: Has a rich library support (Both standard ~ built-
in data structures, algorithms etc.) as well 3rd party libraries (e.g. Boost
libraries) for fast and rapid development.
.
• Compiled Language: C++ is a compiled language, contributing to its
speed.

5
SEE6C/SEZ6E – Client/Server Computing
TM

FEATURES OF C++ - Continuation


• Mid-level language: It is a mid-level language as we can do both
systems-programming (drivers, kernels etc.) and build large-scale
user applications (Photoshop, Game Engines etc.)

• Speed of execution: C++ programs excel in execution speed.


Since, it is a compiled language, and also hugely procedural
.
• Pointer and direct Memory-Access: C++ provides pointer support
which aids users to directly manipulate storage address.

• Object-Oriented: One of the strongest points of the language which


sets it apart from C. Object-Oriented support helps C++ to make
maintainable and extensible programs.

6
SEE6C/SEZ6E – Client/Server Computing
APPLICATIONS OF C++
TM

C++ finds varied usage in applications such as:

• Operating Systems & Systems Programming. e.g. Linux-based OS


(Ubuntu etc.)

• Browsers (Chrome & Firefox)

• Graphics & Game engines (Photoshop, Blender, Unreal-Engine)

• Database Engines (MySQL, MongoDB, Redis etc.)

• Drivers for various computers devices.

• Creation of video games.

• Software for servers and software for specific applications.

7
SEE6C/SEZ6E – Client/Server Computing
TM

ADVANTAGES & DIS-ADVANTAGES OF C++


Advantages Dis-Advantages
• C++ is relatively-low level • It is partially object oriented
and is a system programming language.
programming language.
• It emphasis on instructions
• It has a large Community but not on data

• It has a relatively clear and • It can be generally heavy if


mature standard. not careful.

• Reusability and readability • If data is global does not


provide security.

8
SEE6C/SEZ6E – Client/Server Computing
TM

INTRODUCTION TO OBJECT ORIENTED


PROGRAMMING
The name suggests, Object Oriented Programming or OOPs refers
to languages that use 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.

9
SEE6C/SEZ6E – Client/Server Computing
TM

OOPs Concept:
• Class
• Objects
• Data Abstraction
• Encapsulation
• Inheritance
• Polymorphism
• Dynamic Binding
• Message Passing

10
SEE6C/SEZ6E – Client/Server Computing
TM

CLASS
A class is a user-defined data type. It consists of data members and
member functions, which can be accessed and used by creating an
instance of that class. It represents the set of properties or methods that
are common to all objects of one type. A class is like a blueprint for an
object.
For Example: Consider the Class of Cars. There may be many cars
with different names and brands but all of them will share some
common properties like all of them will have 4 wheels, Speed Limit,
Mileage range, etc. So here, Car is the class, and wheels, speed limits,
mileage are their properties.

11
SEE6C/SEZ6E – Client/Server Computing
TM

OBJECT
It is a basic unit of Object-Oriented Programming and represents
the real-life entities. An Object is an instance of a Class. When a
class is defined, no memory is allocated but when it is instantiated
(i.e. an object is created) memory is allocated. An object has an
identity, state, and behaviour. Each object contains data and code to
manipulate the data. Objects can interact without having to know
details of each other’s data or code, it is sufficient to know the type of
message accepted and type of response returned by the objects.

12
SEE6C/SEZ6E – Client/Server Computing
DATA ABSTRACTION TM

Data abstraction is one of the most essential and


important features of object-oriented
programming. Data abstraction refers to providing
only essential information about the data to the
outside world, hiding the background details or
implementation. Consider a real-life example of a
man driving a car. The man only knows that
pressing the accelerators will increase the speed of
the car or applying brakes will stop the car, but he
does not know about how on pressing the
accelerator the speed is increasing, he does not
know about the inner mechanism of the car or
the implementation of the accelerator, brakes, etc
in the car. This is what abstraction is.
13
SEE6C/SEZ6E – Client/Server Computing
TM

ENCAPSULATION
Encapsulation is defined as the wrapping up of data under a
single unit. It is the mechanism that binds together code and the data
it manipulates. In Encapsulation, the variables or data of a class are
hidden from any other class and can be accessed only through any
member Function of their class in which they are declared. As in
encapsulation, the data in a class is hidden from other classes, so it is
also known as data-hiding.

14
SEE6C/SEZ6E – Client/Server Computing
INHERITANCE TM

Inheritance is an important pillar of


OOP(Object-Oriented Programming). The
capability of a class to derive properties and
characteristics from another class is called
Inheritance. When we write a class, we
inherit properties from other classes. So
when we create a class, we do not need to
write all the properties and functions again and
again, as these can be inherited From another
class that possesses it. Inheritance allows the
user to reuse the code whenever possible and
reduce its redundancy.
15
SEE6C/SEZ6E – Client/Server Computing
TM

16
SEE6C/SEZ6E – Client/Server Computing
TM

POLYMORPHISM
The word polymorphism mean is having many forms. In
simple words, we can define polymorphism as the ability of a
message to be displayed in more than one form. For
example, A person at the same time can have different
characteristics. Like a man at the same time is a father, a
husband, an employee. So the same person posses different
behaviour in different situations. This is called polymorphism.

17
SEE5C – Client/Server Computing
DYNAMIC BINDING
TM

In dynamic binding, the code to be executed in response to the


function call is decided at runtime. Dynamic binding means that the
code associated with a given procedure call is not known until the time
of the call at run time.

MESSAGE PASSING
Objects communicate with one another by
sending and receiving information to each
other. A 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 results. Message
passing involves specifying the name of the
object, the name of the function and the
information to be sent.

SEE6C/SEZ6E – Client/Server Computing 18


I/0 OPERATIONS IN C++ TM

The C++ standard libraries provide an extensive set of input/output


capabilities which we will see in subsequent chapters. This chapter
will discuss very basic and most common I/O operations required
for C++ programming. C++ I/O occurs in streams,, which are sequences of
bytes.. If bytes flow from a device like a keyboard,, a disk drive, or a
network connection etc... tot main memory, this is called input operation
and if bytes flow from main memory to a device like a display screen, a
printer, a disk drive, or a network connection, etc., this is called output
operation.

19
SEE6C/SEZ6E – Client/Server Computing
I/O Library Header Files TM

There are following header files important to C++ programs.

S.NO Hader Files & Function and Description

1 <iostream>

This file defines the cin,, cout,, cerr and clog objects, which correspond
to the standard input stream,, the standard output stream,, the un--
buffered standard error stream and the buffered standard error stream,
respectively.

2 <iomanip>

This file declares services useful for performing formatted I/O with so--
called parameterized stream manipulators, such as setw and
setprecision..

3 <fstream>

This file declares services for user--controlled file processing. We will


discuss about it in detail in File and Stream related chapter.

20
SEE6C/SEZ6E – Client/Server Computing
The Standard Output Stream (cout) TM

The predefined object cout is an instance of ostream class. The


cout object is said to be "connected to" the standard output device, which usually
is the display screen. The cout is used in conjunction with the stream insertion
operator, which is written as << which are two less than signs as shown in the
following example.

When the above code is compiled and executed, it produces the


following result −
Value of str is : Hello C++

21
SEE6C/SEZ6E – Client/Server Computing
The Standard Input Stream (cin) TM

The predefined object cin is an instance of istream class. The cin object is said to
be attached to the standard input device, which usually is the keyboard. The cin is
used in conjunction with the stream extraction operator, which is written as >>
which are two greater than signs as shown in the following example.

When the above code is compiled and executed, it will prompt you
to enter a name. You enter a value and then hit enter to see the
following result −
Please enter your name: cplusplus
Your name is: cplusplus

22
SEE6C/SEZ6E – Client/Server Computing

You might also like