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:
@ -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.
|
||||
|
||||

|
||||
|
||||
|
||||
## What next?
|
||||
Pick an OO language, and build a basic terminal based game to illustrate these concepts.
|
||||
|
Reference in New Issue
Block a user