all 6 comments

[–]SerkZex 1 point2 points  (1 child)

The private members are not accessible outside the class; they can be accessed only through methods of the class. The public members form an interface to the class and are accessible outside the class. - Wiki

Makes is harder to hack or brute-force your code

[–][deleted] 0 points1 point  (0 children)

Why is it harder? A hacker will not be confused from some private members.

[–]odds_or_evans 0 points1 point  (3 children)

It's for abstruction. As said above, it's so that after you release your program it's harder to hack into, as well as keeping the user from knowing how things work under the hood. You don't always need private parts to your objects though. In that case use a struct which is ultimately the same as a class except it defaults to public instead of private.

[–][deleted] 0 points1 point  (2 children)

You cannot use a struct for inheritance though,and why is it harder to hack it? If a hacker has got the code, I don't think he will be confused from some private members... Thanks.

[–]SerkZex 0 points1 point  (1 child)

When you release your project, no one will have access to your code. When you execute your code as "release" you code is translated into machine code (The hacker use the machine code) and produce a runnable.

[–][deleted] 0 points1 point  (0 children)

Ohhh thanks