Getter and setter , how to use ? What is the need ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Getter and setter , how to use ? What is the need ?

getter and setter

25th May 2018, 5:21 PM
Anshul
Anshul - avatar
1 Answer
+ 1
In OOP it is a common way to capsule data. It's usual to declare the properties of an object as private. So you haven't acces to this datatypes, so you use set and get functions to get public acces to the datatypes. You do this with functions, because you can modify the result/output with parameters. They are much more I can say, but it's better to inform you in the internet.
25th May 2018, 6:17 PM
BraveHornet
BraveHornet - avatar