SlideShare a Scribd company logo
object oriented programming language in c++
C++ Evolution
 The prime purpose of C++ programming was to add object
orientation to the C programming language, which is in
itself one of the most powerful programming languages.
 C++ is regarded as a middle-level language, as it
comprises a combination of both high-level and low-level
language features.
 C++ was developed by Bjarne Stroustrup starting in 1979 at
Bell Labs in Murray Hill, New Jersey, as an enhancement to
the C language and originally named C with Classes but
later it was renamed C++ in 1983.
 C++ is a superset of C, and that virtually any legal C
program is a legal C++ program.
Procedure-oriented Programming
Some Characteristics exhibited by procedure-oriented
programming are:
• Emphasis is on doing things (algorithms).
• Large programs are divided into smaller programs known
as functions.
• Most of the functions share global data.
• Data move openly around the system from function to
function.
• Functions transform data from one form to another.
• Employs top-down approach in program design.
Object Oriented Programming
Some of the features of object oriented programming are:
 Emphasis is on data rather than procedure
 Element in the program development and does not allow it
to flow freely around the system
 OOP allows decomposition of a problem into a number of
entities called objects and then builds data and function
around these
 Programs are divided into what are known as objects
 Functions that operate on the data of an object are ties
together in the data structure.
 Data is hidden and cannot be accessed by external
function.
 Objects may communicate with each other through
function.
 Follows bottom-up approach in program design.
Basic Concepts of Object Oriented
Programming
These include:
 Objects
 Classes
 Data abstraction and encapsulation
 Inheritance
 Polymorphism
Objects
 An object is a software bundle of related state and
behavior.
 Software objects are often used to model the real-
world objects that you find in everyday life.
 That is both data and function that operate on data are
bundled as a unit called as object.
 Objects are the basic run time entities in an object-
oriented system. They may represent a person, a place,
a bank account, a table of data or any item that the
program has to handle. They may also represent user-
defined data such as time and lists.
Organization of Data and Function
object oriented programming language in c++
Class
 A class is a blueprint or prototype from which objects
are created.
 Models the state and behavior of a real-world object.
 This doesn't actually define any data, but it does define
what the class name means, that is, what an object of
the class will consist of and what operations can be
performed on such an object.
 In fact, objects are variables of the type class.
 For examples, Mango, Apple and orange members of
class fruit.
Abstraction
 Data abstraction refers to, providing only essential
information to the outside word and hiding their
background details, i.e., to represent the needed
information in program without presenting the
details.
 Classes use the concept of abstraction and are defined
as a list of abstract attributes such as size, wait, and
cost, and function operate on these attributes.
 The attributes are some time called data members
because they hold information. The functions that
operate on these data are sometimes called methods or
member function.
Encapsulation
 Encapsulation is placing the data and the functions
that work on that data in the same place. While
working with procedural languages, it is not always
clear which functions work on which variables but
object-oriented programming provides you framework
to place the data and the relevant functions together in
the same object.
Inheritance
 One of the most useful aspects of object-oriented
programming is code reusability. As the name suggests
Inheritance is the process of forming a new class from
an existing class that is from the existing class called as
base class, new class is formed called as derived class.
 This is a very important concept of object-oriented
programming since this feature helps to reduce the
code size
Polymorphism
 Polymorphism, a Greek term, means the ability to take
more than on form.
 The ability to use an operator or function in different
ways in other words giving different meaning to the
operators or functions is called polymorphism. Poly
refers to many. That is a single function or an operator
functioning in many ways different upon the usage is
called polymorphism.
 The process of making an operator to exhibit different
behaviors in different instances is known as operator
overloading
 Single function name can be used to handle different
number and different types of argument. This is
something similar to a particular word having several
different meanings depending upon the context. Using
a single function name to perform different type of
task is known as function overloading.
object oriented programming language in c++
Benefits of OOP
 Through inheritance, we can eliminate redundant
code extend the use of existing Classes
 We can build programs from the standard working
modules that communicate with one another, rather
than having to start writing the code from scratch.
This leads to saving of development time and higher
productivity
 The principle of data hiding helps the programmer to
build secure program that can not be invaded by code
in other parts of a programs
 It is easy to partition the work in a project based on
objects.
 Object-oriented system can be easily upgraded from
small to large system.
 Software complexity can be easily managed.
Application of OOP
 Real-time system
 Simulation and modeling
 Object-oriented data bases
 AI and expert systems
 Neural networks and parallel programming
 Decision support and office automation systems
 CIM/CAM/CAD systems
#include<iostream>
using namespace std;
int main()
{
cout << “ C++ is better than C.n”; // C++ statement
return 0;
}
A Simple Program
Printing a Line of Text on the Screen
#include<iostream>
 The #include directive instructs the compiler to
include the contents of the file enclosed within
angular brackets into the source file.
 Contains declarations for the identifier cout and
operator <<
 The header file iostream should be included at the
beginning of all programs that use input/output
statements.
using namespace std;
 Namespace is a new concept introduced by the ANSI
C++ standards committee.
 This defines a scope for the identifiers that are used in
a program.
 Namespace: a naming context to distinguish between
different items with the same name
 C++ namespace: contains classes, variables, constants,
functions, etc.
 For using the identifier defined in the namespace
scope we must include the using directive
 Here, std is the namespace where ANSI C++ standard
class libraries are defined.
cout << “ C++ is better than C.n”;
 Causes the string in quotation marks to be displayed
on the screen.
 This statement introduces two new C++ features,
1. cout
2. <<
 The identifier cout is a predefined object that
represents the standard output stream in C++.
 The operator << is called the insertion or put to
operator.
Comments
// C++ statement
 C++ introduces a new comment symbol // (double
slash).
 The double slash comment is basically a single line
comment. Multiline comments can be written as
follows:
// This is an example of
// C++ program to illustrate
// some of its features
 The C comment symbols /*,*/ are still valid and are
more suitable for multiline comments. The following
comment is allowed:
/* This is an example of
C++ program to illustrate
some of its features
*/
AVERAGE OF TWO NUMBERS
#include<iostream> // include header file
using namespace std;
int main()
{
float number1, number2, sum, average;
cout << “Enter two numbers:”;
cin >> number1; // Read Numbers
cin >> number2; // from keyboard
sum = number1 + number2;
average = sum/2;
cout << ”Sum = “ << sum << “n”;
cout << “Average = “ << average << “n”;
return 0;
} //end of example
The output would be:
Enter two numbers: 6.5 7.5
Sum = 14
Average = 7
cin >> number1
 Is an input statement and causes the program to wait
for the user to type in a number. The number keyed in
is placed in the variable number1.
 The operator >> is known as extraction or get from
operator.
cout << ”Sum = “ << sum << “n”;
Cascading of I/O Operators
 The statement First sends the string “Sum = “ to cout and
then sends the value of sum. Finally, it sends the newline
character so that the next output will be in the new line.
Using the cascading technique, the last two statements can
be combined as follows:
1. Cout << “Sum = “ << sum << “n”
<< “Average = “ << average << “n”;
2. Cout << “Sum = “ << sum << “,”
<< “Average = “ << average << “n”;
 We can also cascade input operator >> as shown below:
Cin >> number1 >> number2;
Example with Class
 One of the major features of C++ is classes. They provide a method of binding
together data and functions which operate on them.
#include<iostream> // include header file
using namespace std;
class person
{
char name[30];
Int age;
public:
void getdata(void);
void display(void);
};
void person :: getdata(void)
{
cout << “Enter name: “;
cin >> name;
cout << “Enter age: “;
cin >> age;
Void person : : display(void)
{
cout << “nNameame: “ << name;
cout << “nAge: “ << age;
}
Int main()
{
person p;
p.getdata();
p.display();
Return 0;
} //end of example
The output of program is:
Enter Name: Ravinder
Enter age:30
Name:Ravinder
Age: 30

More Related Content

Similar to object oriented programming language in c++ (20)

PPT
Unit 5.ppt
JITTAYASHWANTHREDDY
 
PPT
Mca 2 sem u-1 iintroduction
Rai University
 
PPT
73d32 session1 c++
Mukund Trivedi
 
PPTX
Object oriented programming 7 first steps in oop using c++
Vaibhav Khanna
 
PPTX
Programming in c++
MalarMohana
 
PPTX
Programming in c++
sujathavvv
 
PPTX
An introduction to object-oriented programming.pptx
olisahchristopher
 
PPTX
Introduction to C++ Programming
Preeti Kashyap
 
PPTX
Object oriented programming. (1).pptx
baadshahyash
 
PDF
OOPS_Unit_1
Shipra Swati
 
PDF
@vtucode.in-module-1-c++-2022-scheme.pdf
TheertheshTheertha1
 
PDF
C++ Programming with examples for B.Tech
ashutoshgupta1102
 
PPT
The smartpath information systems c plus plus
The Smartpath Information Systems,Bhilai,Durg,Chhattisgarh.
 
PPT
the education purpose of software C++.ppt
FarookMohamed12
 
PPTX
2-oops-concepts_about_c++_btech_cse.pptx
NitinGarg168992
 
DOC
Introduction to OOPs Concept- Features, Basic concepts, Benefits and Applicat...
KrishnaveniT8
 
PDF
Object Oriented Programming With C 2140705 Darshan All Unit Darshan Institute...
hslinaaltosh
 
PPTX
CPP_,module2_1.pptx
AbhilashTom4
 
PPT
C++ basic intro on c++ programming language ppt
PavithraD65
 
Mca 2 sem u-1 iintroduction
Rai University
 
73d32 session1 c++
Mukund Trivedi
 
Object oriented programming 7 first steps in oop using c++
Vaibhav Khanna
 
Programming in c++
MalarMohana
 
Programming in c++
sujathavvv
 
An introduction to object-oriented programming.pptx
olisahchristopher
 
Introduction to C++ Programming
Preeti Kashyap
 
Object oriented programming. (1).pptx
baadshahyash
 
OOPS_Unit_1
Shipra Swati
 
@vtucode.in-module-1-c++-2022-scheme.pdf
TheertheshTheertha1
 
C++ Programming with examples for B.Tech
ashutoshgupta1102
 
The smartpath information systems c plus plus
The Smartpath Information Systems,Bhilai,Durg,Chhattisgarh.
 
the education purpose of software C++.ppt
FarookMohamed12
 
2-oops-concepts_about_c++_btech_cse.pptx
NitinGarg168992
 
Introduction to OOPs Concept- Features, Basic concepts, Benefits and Applicat...
KrishnaveniT8
 
Object Oriented Programming With C 2140705 Darshan All Unit Darshan Institute...
hslinaaltosh
 
CPP_,module2_1.pptx
AbhilashTom4
 
C++ basic intro on c++ programming language ppt
PavithraD65
 

Recently uploaded (20)

PPTX
Numbers of a nation: how we estimate population statistics | Accessible slides
Office for National Statistics
 
PDF
apidays Singapore 2025 - Trustworthy Generative AI: The Role of Observability...
apidays
 
PDF
apidays Singapore 2025 - Building a Federated Future, Alex Szomora (GSMA)
apidays
 
PDF
apidays Singapore 2025 - The API Playbook for AI by Shin Wee Chuang (PAND AI)
apidays
 
PDF
apidays Singapore 2025 - Streaming Lakehouse with Kafka, Flink and Iceberg by...
apidays
 
PPT
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
PDF
Data Retrieval and Preparation Business Analytics.pdf
kayserrakib80
 
PPTX
apidays Munich 2025 - Building an AWS Serverless Application with Terraform, ...
apidays
 
PPTX
apidays Helsinki & North 2025 - From Chaos to Clarity: Designing (AI-Ready) A...
apidays
 
PDF
Avatar for apidays apidays PRO June 07, 2025 0 5 apidays Helsinki & North 2...
apidays
 
PPTX
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
PPTX
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
PDF
Using AI/ML for Space Biology Research
VICTOR MAESTRE RAMIREZ
 
PDF
apidays Helsinki & North 2025 - API-Powered Journeys: Mobility in an API-Driv...
apidays
 
PPTX
apidays Singapore 2025 - From Data to Insights: Building AI-Powered Data APIs...
apidays
 
PDF
The Best NVIDIA GPUs for LLM Inference in 2025.pdf
Tamanna36
 
PPTX
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
PPTX
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
PPTX
Listify-Intelligent-Voice-to-Catalog-Agent.pptx
nareshkottees
 
PDF
JavaScript - Good or Bad? Tips for Google Tag Manager
📊 Markus Baersch
 
Numbers of a nation: how we estimate population statistics | Accessible slides
Office for National Statistics
 
apidays Singapore 2025 - Trustworthy Generative AI: The Role of Observability...
apidays
 
apidays Singapore 2025 - Building a Federated Future, Alex Szomora (GSMA)
apidays
 
apidays Singapore 2025 - The API Playbook for AI by Shin Wee Chuang (PAND AI)
apidays
 
apidays Singapore 2025 - Streaming Lakehouse with Kafka, Flink and Iceberg by...
apidays
 
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
Data Retrieval and Preparation Business Analytics.pdf
kayserrakib80
 
apidays Munich 2025 - Building an AWS Serverless Application with Terraform, ...
apidays
 
apidays Helsinki & North 2025 - From Chaos to Clarity: Designing (AI-Ready) A...
apidays
 
Avatar for apidays apidays PRO June 07, 2025 0 5 apidays Helsinki & North 2...
apidays
 
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
SlideEgg_501298-Agentic AI.pptx agentic ai
530BYManoj
 
Using AI/ML for Space Biology Research
VICTOR MAESTRE RAMIREZ
 
apidays Helsinki & North 2025 - API-Powered Journeys: Mobility in an API-Driv...
apidays
 
apidays Singapore 2025 - From Data to Insights: Building AI-Powered Data APIs...
apidays
 
The Best NVIDIA GPUs for LLM Inference in 2025.pdf
Tamanna36
 
apidays Helsinki & North 2025 - Agentic AI: A Friend or Foe?, Merja Kajava (A...
apidays
 
b6057ea5-8e8c-4415-90c0-ed8e9666ffcd.pptx
Anees487379
 
Listify-Intelligent-Voice-to-Catalog-Agent.pptx
nareshkottees
 
JavaScript - Good or Bad? Tips for Google Tag Manager
📊 Markus Baersch
 
Ad

object oriented programming language in c++

  • 2. C++ Evolution  The prime purpose of C++ programming was to add object orientation to the C programming language, which is in itself one of the most powerful programming languages.  C++ is regarded as a middle-level language, as it comprises a combination of both high-level and low-level language features.  C++ was developed by Bjarne Stroustrup starting in 1979 at Bell Labs in Murray Hill, New Jersey, as an enhancement to the C language and originally named C with Classes but later it was renamed C++ in 1983.  C++ is a superset of C, and that virtually any legal C program is a legal C++ program.
  • 3. Procedure-oriented Programming Some Characteristics exhibited by procedure-oriented programming are: • Emphasis is on doing things (algorithms). • Large programs are divided into smaller programs known as functions. • Most of the functions share global data. • Data move openly around the system from function to function. • Functions transform data from one form to another. • Employs top-down approach in program design.
  • 4. Object Oriented Programming Some of the features of object oriented programming are:  Emphasis is on data rather than procedure  Element in the program development and does not allow it to flow freely around the system  OOP allows decomposition of a problem into a number of entities called objects and then builds data and function around these  Programs are divided into what are known as objects  Functions that operate on the data of an object are ties together in the data structure.  Data is hidden and cannot be accessed by external function.  Objects may communicate with each other through function.  Follows bottom-up approach in program design.
  • 5. Basic Concepts of Object Oriented Programming These include:  Objects  Classes  Data abstraction and encapsulation  Inheritance  Polymorphism
  • 6. Objects  An object is a software bundle of related state and behavior.  Software objects are often used to model the real- world objects that you find in everyday life.  That is both data and function that operate on data are bundled as a unit called as object.  Objects are the basic run time entities in an object- oriented system. They may represent a person, a place, a bank account, a table of data or any item that the program has to handle. They may also represent user- defined data such as time and lists.
  • 7. Organization of Data and Function
  • 9. Class  A class is a blueprint or prototype from which objects are created.  Models the state and behavior of a real-world object.  This doesn't actually define any data, but it does define what the class name means, that is, what an object of the class will consist of and what operations can be performed on such an object.  In fact, objects are variables of the type class.  For examples, Mango, Apple and orange members of class fruit.
  • 10. Abstraction  Data abstraction refers to, providing only essential information to the outside word and hiding their background details, i.e., to represent the needed information in program without presenting the details.  Classes use the concept of abstraction and are defined as a list of abstract attributes such as size, wait, and cost, and function operate on these attributes.  The attributes are some time called data members because they hold information. The functions that operate on these data are sometimes called methods or member function.
  • 11. Encapsulation  Encapsulation is placing the data and the functions that work on that data in the same place. While working with procedural languages, it is not always clear which functions work on which variables but object-oriented programming provides you framework to place the data and the relevant functions together in the same object.
  • 12. Inheritance  One of the most useful aspects of object-oriented programming is code reusability. As the name suggests Inheritance is the process of forming a new class from an existing class that is from the existing class called as base class, new class is formed called as derived class.  This is a very important concept of object-oriented programming since this feature helps to reduce the code size
  • 13. Polymorphism  Polymorphism, a Greek term, means the ability to take more than on form.  The ability to use an operator or function in different ways in other words giving different meaning to the operators or functions is called polymorphism. Poly refers to many. That is a single function or an operator functioning in many ways different upon the usage is called polymorphism.
  • 14.  The process of making an operator to exhibit different behaviors in different instances is known as operator overloading  Single function name can be used to handle different number and different types of argument. This is something similar to a particular word having several different meanings depending upon the context. Using a single function name to perform different type of task is known as function overloading.
  • 16. Benefits of OOP  Through inheritance, we can eliminate redundant code extend the use of existing Classes  We can build programs from the standard working modules that communicate with one another, rather than having to start writing the code from scratch. This leads to saving of development time and higher productivity  The principle of data hiding helps the programmer to build secure program that can not be invaded by code in other parts of a programs
  • 17.  It is easy to partition the work in a project based on objects.  Object-oriented system can be easily upgraded from small to large system.  Software complexity can be easily managed.
  • 18. Application of OOP  Real-time system  Simulation and modeling  Object-oriented data bases  AI and expert systems  Neural networks and parallel programming  Decision support and office automation systems  CIM/CAM/CAD systems
  • 19. #include<iostream> using namespace std; int main() { cout << “ C++ is better than C.n”; // C++ statement return 0; } A Simple Program Printing a Line of Text on the Screen
  • 20. #include<iostream>  The #include directive instructs the compiler to include the contents of the file enclosed within angular brackets into the source file.  Contains declarations for the identifier cout and operator <<  The header file iostream should be included at the beginning of all programs that use input/output statements.
  • 21. using namespace std;  Namespace is a new concept introduced by the ANSI C++ standards committee.  This defines a scope for the identifiers that are used in a program.  Namespace: a naming context to distinguish between different items with the same name  C++ namespace: contains classes, variables, constants, functions, etc.  For using the identifier defined in the namespace scope we must include the using directive  Here, std is the namespace where ANSI C++ standard class libraries are defined.
  • 22. cout << “ C++ is better than C.n”;  Causes the string in quotation marks to be displayed on the screen.  This statement introduces two new C++ features, 1. cout 2. <<  The identifier cout is a predefined object that represents the standard output stream in C++.  The operator << is called the insertion or put to operator.
  • 23. Comments // C++ statement  C++ introduces a new comment symbol // (double slash).  The double slash comment is basically a single line comment. Multiline comments can be written as follows: // This is an example of // C++ program to illustrate // some of its features
  • 24.  The C comment symbols /*,*/ are still valid and are more suitable for multiline comments. The following comment is allowed: /* This is an example of C++ program to illustrate some of its features */
  • 25. AVERAGE OF TWO NUMBERS #include<iostream> // include header file using namespace std; int main() { float number1, number2, sum, average; cout << “Enter two numbers:”; cin >> number1; // Read Numbers cin >> number2; // from keyboard sum = number1 + number2; average = sum/2; cout << ”Sum = “ << sum << “n”; cout << “Average = “ << average << “n”; return 0; } //end of example
  • 26. The output would be: Enter two numbers: 6.5 7.5 Sum = 14 Average = 7
  • 27. cin >> number1  Is an input statement and causes the program to wait for the user to type in a number. The number keyed in is placed in the variable number1.  The operator >> is known as extraction or get from operator.
  • 28. cout << ”Sum = “ << sum << “n”; Cascading of I/O Operators  The statement First sends the string “Sum = “ to cout and then sends the value of sum. Finally, it sends the newline character so that the next output will be in the new line. Using the cascading technique, the last two statements can be combined as follows: 1. Cout << “Sum = “ << sum << “n” << “Average = “ << average << “n”; 2. Cout << “Sum = “ << sum << “,” << “Average = “ << average << “n”;  We can also cascade input operator >> as shown below: Cin >> number1 >> number2;
  • 29. Example with Class  One of the major features of C++ is classes. They provide a method of binding together data and functions which operate on them. #include<iostream> // include header file using namespace std; class person { char name[30]; Int age; public: void getdata(void); void display(void); }; void person :: getdata(void) { cout << “Enter name: “; cin >> name; cout << “Enter age: “; cin >> age;
  • 30. Void person : : display(void) { cout << “nNameame: “ << name; cout << “nAge: “ << age; } Int main() { person p; p.getdata(); p.display(); Return 0; } //end of example The output of program is: Enter Name: Ravinder Enter age:30 Name:Ravinder Age: 30