C++ OOp's, Object Oriented Programming in C++


C++ OOP's ( Object Oriented Programming )

Object Oriented Programming is a programming in which we design and develop our application or program based of object. Objects are instances(variables) of class.

Object oriented programming does not allow data to flow freely around the system. It binds data more closely to the functions that operate on it, and protects it from accidental modifications from outside functions.

Object oriented programming allows separation of a complex programs into objects and then builds data and functions around these objects. The data of an object can be accessed only by the functions associated with that object. However, functions of one object can access the functions of other objects.

Features of OOP's ( Object Oriented Programming )

  • Class : Class is an encapsulation of data and coding. Classes are an expanded version of structures. Structure can contain multiple variables. Classes can contain multiple variables, even more, classes can also contain functions as class member. Variables available in class are called Data Members. Functions available in class are called Member Functions.
  • Object : Class is a user-defined data type and object is a variable of class type. Object is used to access class members.
  • Inheritance : Inheritance means access the properties and features of one class into another class. The class who is going to provide its features to another class will be called base class and the class who is using the properties and features of another class will be called derived class.
  • Polymorphism : Polymorphism means more than one function with same name, with different working. It can be static or dynamic. In static polymorphism memory will be allocated at compile time. In dynamic polymorphism memory will be allocated at runtime. Both function overloading and operator overloading are an examples of static polymorphism. Virtual function is an example of dynamic polymorphism.
  • Data Abstraction : The basic idea of data abstraction is to visible only the necessary information, unnecessary information will be hidden from the outside world. This can be done by making class members as private members of class. Private members can be accessed only within the same class where they are declared.
  • Encapsulation : Encapsulation is a process of wrapping data members and member functions in a single unit called class. Using the method of encapsulation, the programmer cannot directly access the data. Data is only accessible through the object of the class.

Related topics: