SlideShare a Scribd company logo
7
Most read
9
Most read
10
Most read
OOPS- C++ Programming
FY.BSc. IT
Sem-II
No. C C++
1) C follows the procedural style
programming.
C++ is multi-paradigm. It
supports both procedural and
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.
4) C does not support function
overloading.
C++ supports function
overloading.
5) In C, you can't use functions in
structure.
In C++, you can use functions in
structure.
6) C does not support reference
variables.
C++ supports reference variables.
7) In C, scanf() and
printf() are mainly used for
input/output.
C++ mainly uses stream cin and
cout to perform input and output
operations.
8) Operator overloading is
not possible in C.
Operator overloading is possible in
C++.
9) C programs are divided
into procedures and
modules
C++ programs are divided
into functions and classes.
10) C does not provide the
feature of namespace.
C++ supports the feature of
namespace.
11) Exception handling is not
easy in C. It has to perform
using other functions.
C++ provides exception handling
using Try and Catch block.
12) C does not support the
inheritance.
C++ supports inheritance.
C++ programming introduction
C++ programming introduction
#include<iostream.h>
#include<conio.h>
class calculator
{
Int a,b;
public:
void getdata(); for input
void add(); for addition of two number
void sub(); for subtraction of two number
};
void calculator::getdata() define member function
{
cout<<"Enter the First Number:";
cin>>a;
cout<<“Enter the Second Number:";
cin>>b;
}
void calculator::add() define member function
{
cout<<“Addition of A & B is="<<a+b<<“n”;
}
void calculator::sub() define member function
{
cout<<“Subtraction of A & B is="<<a-b<<“n”;
}
void main()
{
clrscr();
calculator c;
c.getdata();
c.add();
c.sub();
getch();
Class and Object
Member Functions in Classes
There are 2 ways to define a member function:
• Inside class definition
• Outside class definition
To define a member function outside the class
definition we have to use the scope resolution ::
operator along with class name and function
name.
Inside the Class
class student
{
public:
int id;
// getdata() is not defined inside class definition
void getdata();
//getdata() is defined inside class definition
void getdata()
{
cout << "student id is: " << id;
} };
Outside the class
// Definition of getdata using scope resolution operator ::
void student::getdata()
{
cout << “Data is: " << sid;
}
Object Oriented Programming Concepts
• Objects
• Classes
• Abstraction & Encapsulation
• Polymorphism
• Inheritance
• Dynamic Binding
• Message Passing
C++ programming introduction
C++ programming introduction
Objects
Objects are the basic unit of OOP. They are
instances of class, which have data members
and uses various member functions to perform
tasks.
When a program is executed the objects interact
by sending messages to one another.
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.
Class
Class can also be defined as user defined data type
but it also contains functions in it. So, class is
basically a blueprint for object. It declare & defines
what data variables the object will have and what
operations can be performed on the class's object.
Example: Consider the Class of Cars. There may
be many cars with different names and brand 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.
Abstraction
Abstraction refers to showing only the essential
features of the application and hiding the details. In
C++, classes can provide methods to the outside
world to access & use the data variables, keeping
the variables hidden from direct access, or classes
can even declare everything accessible to everyone,
or maybe just to the classes inheriting it. This can be
done using access specifiers.
Encapsulation
It can also be said data binding. Encapsulation is all
about binding the data variables and functions
together in class.
Polymorphism
The word polymorphism means having many
forms. In simple words, we can define
polymorphism as the ability of a message to
be displayed in more than one form.
A person at the same time can have different
characteristic. 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.
Example
Inheritance
The capability of a class to derive properties and
characteristics from another class is called Inheritance.
Reusability: Inheritance supports the concept of
“reusability”, i.e. when we want to create a new class
and there is already a class that includes some of the
code that we want, we can derive our new class from
the existing class. By doing this, we are reusing the fields
and methods of the existing class.
Sub Class: The class that inherits properties from
another class is called Sub class or Derived Class.
Super Class: The class whose properties are inherited by
sub class is called Base Class or Super class.
Example:
Dog, Cat, Cow can be Derived Class of Animal Base Class.
Dynamic Binding: In dynamic binding, the code to
be executed in response to function call is decided at
runtime. C++ has virtual functions to support this.
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.
Example: <objectname.memberfunction>

More Related Content

PPTX
Constructor and Destructors in C++
PPTX
Exception handling in c++
PPT
YCMOU_FYBCA_DS_Unit-7.ppt
PPTX
Templates in C++
PPTX
Inheritance in c++
PPTX
Polymorphism in c++(ppt)
PDF
Python Decision Making
PPTX
Principal source of optimization in compiler design
Constructor and Destructors in C++
Exception handling in c++
YCMOU_FYBCA_DS_Unit-7.ppt
Templates in C++
Inheritance in c++
Polymorphism in c++(ppt)
Python Decision Making
Principal source of optimization in compiler design

What's hot (20)

PPTX
Presentation1
PDF
Python file handling
PPT
Formatted input and output
PDF
Java programming lab manual
PPTX
Computer Science-Data Structures :Abstract DataType (ADT)
PPT
Thrashing allocation frames.43
PPTX
Object Oriented Programming Using C++
PPTX
Polymorphism In c++
PPTX
Polymorphism in java
PPTX
Functions in c++
PPTX
Control structures in c++
PDF
Constructors and Destructors
PPTX
Templates in c++
PDF
Memory Management C++ (Peeling operator new() and delete())
PPS
String and string buffer
PPTX
Code Optimization
PDF
PPT
Introduction to method overloading &amp; method overriding in java hdm
Presentation1
Python file handling
Formatted input and output
Java programming lab manual
Computer Science-Data Structures :Abstract DataType (ADT)
Thrashing allocation frames.43
Object Oriented Programming Using C++
Polymorphism In c++
Polymorphism in java
Functions in c++
Control structures in c++
Constructors and Destructors
Templates in c++
Memory Management C++ (Peeling operator new() and delete())
String and string buffer
Code Optimization
Introduction to method overloading &amp; method overriding in java hdm
Ad

Similar to C++ programming introduction (20)

PPTX
OOP CHAPTER object oreinted programming using c++
PPT
PPTX
Lecture 1.pptx
PPTX
Object oriented programming. (1).pptx
PPTX
c++.pptxwjwjsijsnsksomammaoansnksooskskk
PPTX
C++ & Data Structure - Unit - first.pptx
PPTX
Rajib Ali Presentation on object oreitation oop.pptx
PPT
Bca 2nd sem u-1 iintroduction
PPTX
Chapter 2 OOP using C++ (Introduction).pptx
PPT
Mca 2 sem u-1 iintroduction
PPTX
C++ first s lide
PPT
The smartpath information systems c plus plus
PPTX
CSC2161Programming_in_Cpp_Lecture4-OOP Classes and Objects[1].pptx
PPT
the education purpose of software C++.ppt
PPTX
OOC MODULE1.pptx
PPTX
object oriented programming language in c++
PPTX
Introduction to C++ Programming
PPTX
C++ tutorial assignment - 23MTS5730.pptx
OOP CHAPTER object oreinted programming using c++
Lecture 1.pptx
Object oriented programming. (1).pptx
c++.pptxwjwjsijsnsksomammaoansnksooskskk
C++ & Data Structure - Unit - first.pptx
Rajib Ali Presentation on object oreitation oop.pptx
Bca 2nd sem u-1 iintroduction
Chapter 2 OOP using C++ (Introduction).pptx
Mca 2 sem u-1 iintroduction
C++ first s lide
The smartpath information systems c plus plus
CSC2161Programming_in_Cpp_Lecture4-OOP Classes and Objects[1].pptx
the education purpose of software C++.ppt
OOC MODULE1.pptx
object oriented programming language in c++
Introduction to C++ Programming
C++ tutorial assignment - 23MTS5730.pptx
Ad

More from sandeep54552 (20)

PPTX
Dijkstra Searching Algorithms Shortest.pptx
PPTX
E_R-Diagram (2).pptx
PPTX
Dijkstra Searching Algorithms.pptx
PPTX
DFS_New.pptx
PPT
Agents_AI.ppt
PPTX
Queue_Data_Structure.pptx
PPTX
Tree_Definition.pptx
PPTX
Stack_Application_Infix_Prefix.pptx
PPTX
Stack_Data_Structure.pptx
PPTX
Heap_Sort1.pptx
PPTX
Quick_sort1.pptx
PPTX
Link_List.pptx
PPTX
File handling in c++
PPTX
Jsp tag library
PDF
Hill climbing algorithm in artificial intelligence
PPTX
Session bean
PPTX
Greedy algorithms
PPTX
A star algorithms
PPTX
Bfs new
PPTX
Bfs new
Dijkstra Searching Algorithms Shortest.pptx
E_R-Diagram (2).pptx
Dijkstra Searching Algorithms.pptx
DFS_New.pptx
Agents_AI.ppt
Queue_Data_Structure.pptx
Tree_Definition.pptx
Stack_Application_Infix_Prefix.pptx
Stack_Data_Structure.pptx
Heap_Sort1.pptx
Quick_sort1.pptx
Link_List.pptx
File handling in c++
Jsp tag library
Hill climbing algorithm in artificial intelligence
Session bean
Greedy algorithms
A star algorithms
Bfs new
Bfs new

Recently uploaded (20)

PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Pre independence Education in Inndia.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
RMMM.pdf make it easy to upload and study
PPTX
Lesson notes of climatology university.
PPTX
master seminar digital applications in india
PDF
Classroom Observation Tools for Teachers
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Cell Types and Its function , kingdom of life
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
human mycosis Human fungal infections are called human mycosis..pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
Microbial diseases, their pathogenesis and prophylaxis
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
O7-L3 Supply Chain Operations - ICLT Program
Pre independence Education in Inndia.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
GDM (1) (1).pptx small presentation for students
RMMM.pdf make it easy to upload and study
Lesson notes of climatology university.
master seminar digital applications in india
Classroom Observation Tools for Teachers
STATICS OF THE RIGID BODIES Hibbelers.pdf
Cell Types and Its function , kingdom of life
PPH.pptx obstetrics and gynecology in nursing
Pharmacology of Heart Failure /Pharmacotherapy of CHF

C++ programming introduction

  • 2. No. C C++ 1) C follows the procedural style programming. C++ is multi-paradigm. It supports both procedural and 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. 4) C does not support function overloading. C++ supports function overloading. 5) In C, you can't use functions in structure. In C++, you can use functions in structure. 6) C does not support reference variables. C++ supports reference variables.
  • 3. 7) In C, scanf() and printf() are mainly used for input/output. C++ mainly uses stream cin and cout to perform input and output operations. 8) Operator overloading is not possible in C. Operator overloading is possible in C++. 9) C programs are divided into procedures and modules C++ programs are divided into functions and classes. 10) C does not provide the feature of namespace. C++ supports the feature of namespace. 11) Exception handling is not easy in C. It has to perform using other functions. C++ provides exception handling using Try and Catch block. 12) C does not support the inheritance. C++ supports inheritance.
  • 6. #include<iostream.h> #include<conio.h> class calculator { Int a,b; public: void getdata(); for input void add(); for addition of two number void sub(); for subtraction of two number };
  • 7. void calculator::getdata() define member function { cout<<"Enter the First Number:"; cin>>a; cout<<“Enter the Second Number:"; cin>>b; } void calculator::add() define member function { cout<<“Addition of A & B is="<<a+b<<“n”; }
  • 8. void calculator::sub() define member function { cout<<“Subtraction of A & B is="<<a-b<<“n”; } void main() { clrscr(); calculator c; c.getdata(); c.add(); c.sub(); getch();
  • 10. Member Functions in Classes There are 2 ways to define a member function: • Inside class definition • Outside class definition To define a member function outside the class definition we have to use the scope resolution :: operator along with class name and function name.
  • 11. Inside the Class class student { public: int id; // getdata() is not defined inside class definition void getdata(); //getdata() is defined inside class definition void getdata() { cout << "student id is: " << id; } };
  • 12. Outside the class // Definition of getdata using scope resolution operator :: void student::getdata() { cout << “Data is: " << sid; }
  • 13. Object Oriented Programming Concepts • Objects • Classes • Abstraction & Encapsulation • Polymorphism • Inheritance • Dynamic Binding • Message Passing
  • 16. Objects Objects are the basic unit of OOP. They are instances of class, which have data members and uses various member functions to perform tasks. When a program is executed the objects interact by sending messages to one another. 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.
  • 17. Class Class can also be defined as user defined data type but it also contains functions in it. So, class is basically a blueprint for object. It declare & defines what data variables the object will have and what operations can be performed on the class's object. Example: Consider the Class of Cars. There may be many cars with different names and brand 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.
  • 18. Abstraction Abstraction refers to showing only the essential features of the application and hiding the details. In C++, classes can provide methods to the outside world to access & use the data variables, keeping the variables hidden from direct access, or classes can even declare everything accessible to everyone, or maybe just to the classes inheriting it. This can be done using access specifiers. Encapsulation It can also be said data binding. Encapsulation is all about binding the data variables and functions together in class.
  • 19. Polymorphism The word polymorphism means having many forms. In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form. A person at the same time can have different characteristic. 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.
  • 21. Inheritance The capability of a class to derive properties and characteristics from another class is called Inheritance. Reusability: Inheritance supports the concept of “reusability”, i.e. when we want to create a new class and there is already a class that includes some of the code that we want, we can derive our new class from the existing class. By doing this, we are reusing the fields and methods of the existing class. Sub Class: The class that inherits properties from another class is called Sub class or Derived Class. Super Class: The class whose properties are inherited by sub class is called Base Class or Super class.
  • 22. Example: Dog, Cat, Cow can be Derived Class of Animal Base Class.
  • 23. Dynamic Binding: In dynamic binding, the code to be executed in response to function call is decided at runtime. C++ has virtual functions to support this. 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. Example: <objectname.memberfunction>