Está en la página 1de 1

Object-oriented programming, or OOP, is an approach to problem-solving where all

computations are carried out using objects. An object is a component of a progr


am that knows how to perform certain actions and how to interact with other elem
ents of the program. Objects are the basic units of object-oriented programming.
A simple example of an object would be a person. Logically, you would expect a
person to have a name. This would be considered a property of the person. You wo
uld also expect a person to be able to do something, such as walking. This would
be considered a method of the person.
A method in object-oriented programming is like a procedure in procedural progra
mming. The key difference here is that the method is part of an object. In objec
t-oriented programming, we first create classes, then objects for those classes
and then use these objects to build final solution to the problem. This is calle
d bottom-up design or object oriented design. Examples of object oriented langua
ges include C++, Smalltalk, Java etc.
A key aspect of object-oriented programming is the use of classes. A class is a
blueprint of an object. You can think of a class as a concept, and the object as
the embodiment of that concept. So let's say you want to use a person in your p
rogram. You want to be able to describe the person and have the person do someth
ing. A class called 'person' would provide a blueprint for what a person looks l
ike and what a person can do. Examples of object-oriented languages include C++,
C#, Java, Perl and Python.
C++ and Object-Oriented Programming
C++ introduces object-oriented programming (OOP) features to C. It offers classe
s, which provide the four features commonly present in OOP (and some non-OOP) la
nguages: abstraction, encapsulation, inheritance, and polymorphism.
Abstraction:
Data abstraction refers to, providing only essential information to the outside
world and hiding their background details, i.e., to represent the needed informa
tion in program without presenting the details.
For example, a database system hides certain details of how data is stored and c
reated and maintained. Similar way, C++ classes provides different methods to th
e outside world without giving internal detail about those methods and data.
Encapsulation:
Encapsulation is placing the data and the functions that work on that data in th
e same place. While working with procedural languages, it is not always clear wh
ich functions work on which variables but object-oriented programming provides y
ou framework to place the data and the relevant functions together in the same o
bject.
Inheritance:
One of the most useful aspects of object-oriented programming is code reusabilit
y. As the name suggests Inheritance is the process of forming a new class from a
n existing class. This is a very important concept of object-oriented programmin
g since this feature helps to reduce the code size.
Polymorphism:
The ability to use an operator or function in different ways is called polymorph
ism.

También podría gustarte