|
 |
Darren New <dne### [at] san rr com> wrote:
> He's saying that putting "private:" before the variables in a class
> declaration is equivalent to naming private variables with an underscore. In
> the first case, the compiler warns you if you use a private variable by
> mistake. In the second case, it's obvious from inspection. If you have
> x._y
> in your code, you're doing something wrong. :-)
Btw (not flaming here), what would be the naming convention for nested
classes? Take, for example, this kind of situation, in C++ code:
class OuterClass
{
public:
// Public interface here.
private:
// Outside code should not access anything from this point forwards.
// This includes the 'InnerClass' class below.
class InnerClass
{
public:
// Public interface for OuterClass to use.
private:
// Private members of InnerClass. OuterClass should not access.
};
};
While it becomes complex, it's possible to have even a *third* nested
class, inside 'InnerClass', with the equivalent access rules.
(Defining 'InnerClass' outside of 'OuterClass' is not a viable solution
if I really want 'InnerClass' to be strictly inside the scope of
'OuterClass' and nowhere else, because my class design calls for this.)
--
- Warp
Post a reply to this message
|
 |