Added few more lines about OO programming. (#21587)

* Added few more lines about OO programming.

Hope it'll help.

* fix: formatting
This commit is contained in:
Ralphie99
2018-10-22 16:34:49 +05:30
committed by Aditya
parent 71ca568f70
commit 3243105681

View File

@ -23,5 +23,13 @@ Another extremely useful concept is that of inheritance. The idea is that a clas
This helps in reusing code and making you rcode structure much more clean. Data hiding is another cool feature. In OO, we have the notion of private and public attributes. Private attributes can be accessed and modified only by methods of that particular class, while public data can be modified from anywhere in the program (within scope obviously).
OO programming represents problem as a real-life statement and thus helps us solve those problems in an effective way. An object in OO programming represents a real-life entity. A class represents a blueprint of a number of objects. An object can be considered as a instance of a class.
### Example:
See the image below. It represents a blueprint of a class named car. An instance of this class can be a real-life car that performs functionalities such as getFuel(), setSpeed(), drive(), etc.
![a](https://user-images.githubusercontent.com/32509775/47198274-f25d1680-d388-11e8-8909-44111f747b75.png)
## What next?
Pick an OO language, and build a basic terminal based game to illustrate these concepts.