Private or Public

Hi guys,

Is there anyone who can explain to me, or direct me to an article in plain English, that explains the difference between Public and Private under the header file? This area is one of the many that I just don’t get.

Thanks!

Does this code example help?

https://godbolt.org/z/EM9WcjEn3

If you would like it in non-code:

Basically its permission of use similar to what you give to a car key.

If everything is private, possibly only you have permission to use it (anyone who has private use of your home might consider that having permission if needed also).

Public would mean that basically anyone that can gain access to the key is allowed use.

Always best to use the most restricted choice possible as its better for security. Like you wouldn’t just go and make your car key public unless that was by choice as anyone who could grab your key could just go and use your car. But, for certain reasons public has to be used. I suppose that might be similar to car sharing services.

I hope that’s not too simple of an explanation.

Thanks guys! The fog is slowly lifting ;).

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms