Object Oriented Programming C++
Object Oriented Programming C++
C++
PRAMILA CHANDEL
WHAT IS C++?
C++ is the most used and most popular programming language developed by
Bjarne Stroustrup.
C++ is a high-level and object-oriented programming language. This language
allows developers to write clean and efficient code for large applications and
software development, game development, and operating system programming.
It is an expansion of the C programming language to include Object Oriented
Programming(OOPs) and is used to develop programs for computers.
WHY WE NEED C++
• As The name is given OOPS i.e. object oriented programming language which
introduced the object orientation .
• It implements all the OOPs concepts such as Abstraction, Encapsulation, and
Inheritance, which gives a clear structure to programs and allows code to be reused,
lowering development costs and providing security.
• C++ is easy to learn so that you can choose it as your first programming language.
• It makes programming easy for programmers to switch to C++ because its syntax is
similar to C, Java, and C#.
Features of C++
• Simple
• Abstract Data types
• Machine Independent or Portable
• Mid-level programming language
• Structured programming language
• Rich Library
• Memory Management
• Quicker Compilation
• Pointers
• Recursion
• Extensible
• Object-Oriented
• Compiler based
• Reusability
Concept of OOPs
There are Eight type of concept of OOPs.
1. Class
2. Object
3. Encapsulation
4. Abstraction
5. Inheritance
6. Polymorphism
7. Message Passing
8. Dynamic Binding.
Class
• The blue print of an entity which defines the core property and function of
that entities or the blue print for the object is known as the class . Or we can
say that the group of object which shares the common attributes .
A class is a datatype that has its own members. i.e Data member and Member
function .To understand this let us firstly go through the syntax of class
class classname{
Access Specifier:
Data Member;
Member function( )
{
Body
}
};
Here the class is an Keyword and in the place of the classname we can use any name which we want to give for example: student,employee ,worker, any
name we can give
Access specifier – Through which we can access the member of the class .
There are three methods to access the members
1. public
2. private
3. protected
Data Member-Data Members are the variable of the class like int a,flat salary ,char name etc these are the members of the class .
Member Function- It Define the behavior of the class . It is used to manuplate the data .
So here in the syntax which is given a class is an combination of Data Member and Member Function .
class classname{
Access Specifier:
Data Member;
Member function( )
{
Body
}
};
class student{
public:
int a;
Float b;
Char c;
void fun( )
{
cout<<“the class a”<<a;
}
};
We declare the class Outside the main function only .
OBJECT
• The Object is an entity that is created to allocate the memory to the class .
To use the data and access functions defined in the class, we need to create
objects.
Syntax
Classname objectname;
Example
Student obj;
Abstraction
• Abstraction means only showing the important details to thewporld and
hiding other information .
• For example
The man only knows that pressing the accelerator will increase the speed of the
car or applying brakes will stop the car but he does not know how on pressing
the accelerator the speed is actually 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.
Encapsulation
It is used to wrapping up of data and information in a single unit. In Object Oriented
Programming, Encapsulation is defined as binding together the data and the functions that
manipulate them.
a real-life example of encapsulation, in a company, there are different sections like the accounts
section, finance section, sales section, etc. Now,the finance section handles all the financial
transactions and keeps records of all the data related to finance.Similarly, the sales section handles all
the sales-related activities and keeps records of all the sales.Now there may arise a situation when for
some reason an official from the finance section needs all the data about sales in a particular
month.in this case, he is not allowed to directly access the data of the sales section. He will first have
to contact some other officer in the sales section and then request him to give the particular
data.This is what Encapsulation is. Here the data of the sales section and the employees that can
manipulate them are wrapped under a single name “sales section”.
Two Important property of Encapsulation
THANKS