CPP Tutorial

CPP examples programs

CPP OOPs Concepts

CPP introduced the features of OOPs Concept, i.e, CPP is an object-oriented programming language which uses classes and objects for computations. However, it is not considered to be truly object-oriented programming language.

Advantages of Object Oriented Programming Language:

  • Development and maintenance of is easier than the procedural programming.
  • Easy to solve the real world problems as it does not works on step by step instructions.
  • Data are more secure due to its special feature of data hiding.

Principles of OOPs:

An object oriented programming is based on seven fundamental principles.

  1. Object
  2. Class
  3. Method
  4. Inheritance
  5. Polymorphism
  6. Encapsulation
  7. Data Abstraction

 

Object:

Anything that has state and behavior can be termed as an Object, be it physical or logical. An Object is an entity mentioned in OOPs concept and is frequently found in CPP codes.

 Class:

A collection of Objects is termed as Class in OOPs concept. Every class has its own unique and distinguishable attributes and methods.

Method:

Method is similar to a function. It is just a name given to a function associated with an object. That is, in OOPs concept function is termed as Method. In CPP, object of any type can have methods which is not necessarily unique to any class instance.

Inheritance:

The property of acquiring all the properties and behaviors of the parent object by an object is termed as inheritance in OOPs. This is a unique feature in object oriented programming languages which facilitates reusability of the code of the parent class by the derived class.

Polymorphism:

OOPs is based on the principle of Polymorphism, which means, that one task can be performed in many ways.

Encapsulation: 

OOPs restrict direct access to its methods and variables by encapsulating the code and data together.

Data Abstraction

OOPS Data Abstraction feature is used for hiding internal details and showing the functionality only.