Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Public vs Private (vs Protected)

Name: Anonymous 2011-05-19 20:39

Alright /prog/, do you prefer to default your class' members to public or private and why?

class dude : person {
public:
  int var1, var2;
};


or

class dude : person {
  int var1, var2;
};

Name: Anonymous 2011-05-19 21:09

>>11

The idea is to retain control over your classes. Consider the default to be private and you need a reason to go to higher availability. While using interfaces prevents users from using your implementation, it doesn't help if someone inherits your class.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List