0
what is the difference
https://code.sololearn.com/cIlF4cN0i6Dg/?ref=app https://code.sololearn.com/cOfd9bBGQ404/?ref=app snd how to call private function
4 Answers
+ 1
You need to use another public function from the main :
https://code.sololearn.com/cKM0XWByEL7c/?ref=app
Here, the code run like this :
main()
publicFunction()
privateFunction()
return
+ 1
https://code.sololearn.com/cxu3rFutRK29/?ref=app
In this code I try to change the value of 'name' from the main(). But as 'name' is a private variable of 'myClass', it will output a compile error if you run it.
Private membres are only accessible by functions of the class.
Public membres are accessible by every functions in the code.
If you haven't understand, ask!
If you want more informations, ask!
If you want progress, code!
+ 1
thanks
so to use a private function I need to mention it in a public function first
right???
0
so how to use private function in main function and why is private function used.