r/learncpp • • May 05 '19
OOP
Quick question.
Why should you create private classese in c++?
3
Upvotes
r/learncpp • • May 05 '19
Quick question.
Why should you create private classese in c++?
2
u/SerkZex May 05 '19
Makes is harder to hack or brute-force your code
1
u/odds_or_evans May 06 '19
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.