Min menu

Pages

VB

concept of object oriented programming (OOP) in C++

The concept of object-oriented programming(OOP)  in C++

object-oriented programming(Object Oriented Programming)And that is abbreviated with the wordOOPIt is a technique we use in writing code to make writing code easier.
So, object-oriented programming is just a method of working and nothing more, and it is not specific to a languageC++As it is applied in other programming languages.

The idea of ​​object-oriented programming in general is to prepare the form in which information will be saved, making it very easy to access and modify it.

As a simple example, if you intend to build a program to store user information, you will prepare the general form of the information you intend to store for each user.
Then, any new user you intend to create, make it a copy of the general form of any user and make it enter its own values ​​as in the following image.


Now, you need to know that the new type or shape that you are preparing in order to create copies of it later is called the raw version(Blue Print).
The word "raw copy" means the original copy that is prepared for the purpose of creating copies of it.

inC++You have two options to create a new type:

  • To create it with the wordstruct

  • To create it with the wordclass

Note: You will learn the difference between these two words later in the course.


What is the object in C++ ?

In general, the object(Object)A copy of a specific type defined primarily by a word structor wordclass.


Realistic examples of the role of organisms in C++

One of the most common types of projects that you may find dealing with a huge number of objects is game programming.

As a simple example, in any game you play you will find that there is a villain, but this villain may appear to you hundreds of times in the game.
Also in some games you will find rain falling, and to be more precise, you will find the same raindrop falling in different places on the screen.

So in games, a villain is originally equipped once and whenever they want to show you the same villain, they just create a copy of it.
And even for rain, it is also possible to prepare one raindrop and whenever they want to show you rain, they create dozens of copies of it and show them in different places.