+ 1
Why we use public in c++
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 !!!
+ 2
đ