Why we use public in c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why we use public in c++

30th May 2019, 5:01 AM
challa anil
challa anil - avatar
2 Answers
+ 15
► Data members or member functions which are declared as public can be accessed anywhere in the program (within the same class or outside of the class). ► You can access public data members or function directly by using dot operator (.) or arrow operator-> with pointer. ► Using public with your data can be used when you want to make your data accessible at any level i.e. no restrictions for anyone, anyone can access it. Hope this helps !!!
30th May 2019, 6:33 AM
Nova
Nova - avatar
+ 2
😊
30th May 2019, 6:37 AM
challa anil
challa anil - avatar