Object Oriented Programming (OOP) is a programming paradigm that is based on the concept of objects. An object is a data structure that contains data (fields) and functions (methods).
Objects are instances of classes. In OOP a class can be compared with a blueprint or a template for objects. Class is a description of what data and methods should have an object of this class.
C++ provides possibility to combine both procedural and object oriented programming paradigm.
Object Oriented Programming is based on the following concepts:
- Classes of objects.
- Instances of classes (objects).
- Encapsulation – a class encapsulates all the fields and functions that are performed on the fields of a class. The results of encapsulation are:
- Restriction to access some of the object’s data from outside of class.
- Bundling data to functions inside a class.
The encapsulation is described in details in “C++ Encapsulation” topic.
- Polymorphism – a way to use the same interface for the different data types. In simple words it can be described as using the same name for member functions that have different arguments. Polymorphism is not only related to member functions. It’s discussed in more details in “C++ Polymorphism”
- Inheritance – a class can inherit some properties from another class. This means that a child class can use some of the functionality of parent class. You can find more information about inheritance in C++ Inheritance.
- Abstraction – consists in hiding the details of some processes and data and representing only necessary information and result outside the class. The detailed description of the abstraction concept can be found in “C++ Abstraction”.
- Overloading – represents a kind of polymorphism. There is a possibility to overload already existing functions and operators to make them work with new data types. The overloading is described in “C++ Overloading”
- Error handling – some of the errors can appear in run time. Because of this, there is a need to handle errors to make programs safe. The mechanism of C++ error handling is described in “C++ Exception Handling”.