Basic concepts of object oriented programming in C++

The blog covers the basic concepts of object oriented programming in c++  

In software construction, object-oriented programming is a way to construct software  although there are many types of programming languages are available such as

  • Structured programming language
  • Function oriented  programming language
  • Aspect-oriented programming language(AOP)
  • Object-oriented programming language(OOPS)

A well known and famous programming language is an object-oriented programming language that all the current programming supports oops

Concept of oops

Let us understand the concept of oops through function-oriented language such as C

Why?

 because C support C++

The people who know C++ are well aware of C so, I will use C to explain OOPS

Suppose if I am developing a software  for school management system then I will look at that system by a collection of function if I am using function-oriented language such as C

The user of the system will be utilizing this function to complete his tasks

So, you can develop software  in the form of a collection of functions if you are using function-oriented programming

The software “school management system” will be based on a collection of function

Rendered by QuickLaTeX.com

The above figure shows the  example of software development  in a function-oriented language

the software  called “school management system” contain four functions such as

student_name(); 

student_roll_no();

 student_fees();

and student_age();

For object-oriented programming language

such as C++ the complete software consists of a collection of objects

Where Each object will have its function and data

The user of the system will be utilizing these objects to complete his tasks

Object-oriented language is best suited for large size systems

Rendered by QuickLaTeX.com

The above figure a software called “school management system”

where it contain four departments which are nothing but objects and each object will have relevant function + data

Fundamentals of object-oriented programming language

  • Classes
  • Objects
  • reusability
  • Abstraction
  • Inheritance
  • Polymorphism

What is a class? And what is an object?

In simple terms think class as datatype [float] and object is a variable of that float data type

Class and Object

Rendered by QuickLaTeX.com

Here Bird is class and parrot and owl are the object

Rendered by QuickLaTeX.com

Here flower is a class and rose and lily are the object

The structure of a class contains

Two keywords

  • Public
  • Private

Public: means data and functions  can be accessed outside the class

Private: means data and functions are hidden that it cannot be accessed outside the class by other functions

Reusability

Once you have created a class and tested then it can be redistributed to the other members of your team to use it in their code

New instances of classes can be created from existing class instead of redeveloping the existing code

It will save time for the  other member of a team they won’t waste time in rediscovering the wheel instead they will focus on writing a new code

Abstraction

Think abstraction as a password or a key given to you to just login into your account without worrying about how the whole the systems works

Another example consider a laptop  and the abstract for  laptop is a keyboard pad  through which you control the laptop

 you should not  need to know how motherboards work with its transistors, capacitors, resistors, microcontroller so, in a way, it reduces the complexity for you

in C++ you use the headers file without knowing all its internal function for example you use “cout” in the program to print output on the screen

here “cout” is  abstract for you because you just know the “cout” and you don’t know all its internal functions that produce output on the screen

Mohammed Anees

Hey there, welcome to aneescraftsmanship I am Mohammed Anees an independent developer/blogger. I like to share and discuss the craft with others plus the things which I have learned because I believe that through discussion and sharing a new world opens up

Leave a Reply

Your email address will not be published.