+ 1

Why members of class are set to 'private' by default? Why not 'public'?

1st Jun 2017, 11:10 AM
Sudhir Rupapara
Sudhir Rupapara - avatar
3 ответов
+ 2
To enforce encapsulation. Better safe than sorry I always think.
1st Jun 2017, 11:40 AM
Heinrich Cilliers
Heinrich Cilliers - avatar
+ 1
If you want something with default members set to public by default, check out a struct, which is exactly that, a class whose members default to public.
1st Jun 2017, 2:15 PM
Madera Oxidada
Madera Oxidada - avatar
0
You should have to check what's public so that nobody breaks anything
13th Sep 2017, 5:48 PM
Tiger Jones
Tiger Jones - avatar