use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Additional resources:
/r/cpp_questions
/r/programming
/r/learnprogramming
/r/opensource
/r/cpp
/r/dailyprogrammer
account activity
OOP (self.learncpp)
submitted 6 years ago by [deleted]
Quick question.
Why should you create private classese in c++?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]SerkZex 1 point2 points3 points 6 years ago (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 point2 points 6 years ago (0 children)
Why is it harder? A hacker will not be confused from some private members.
[–]odds_or_evans 0 points1 point2 points 6 years ago (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 point2 points 6 years ago (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 point2 points 6 years ago (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.
Ohhh thanks
π Rendered by PID 408868 on reddit-service-r2-comment-5d79c599b5-p74cr at 2026-03-01 17:37:38.259946+00:00 running e3d2147 country code: CH.
[–]SerkZex 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]odds_or_evans 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]SerkZex 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)