Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
nicolasgz
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
9 ms
·
1.
▲
by
nicolasgz
13y ago
> you should always prefer private to protected and protected to public It's well known that protected is not any safer than public. Anybody can inherit and use it. You can still make members private in structs. It's only less
2.
▲
by
nicolasgz
13y ago
Every C++ class declaration ever looks like this: class Foo { public: stuff; private: other stuff; }; What's the point of private-by-default if everybody overrides it anyways?
3.
▲
by
nicolasgz
13y ago
> structs are raw data structures while classes are fully featured OOP entities. Don't put they in the same box. That's not true. Structs and classes are identical except for the minor functional differences highlighted in the
4.
▲
by
nicolasgz
13y ago
Although it should be possible per standard C++, Microsoft's compilers have trouble dealing with it.
5.
▲
by
nicolasgz
13y ago
don't forget the ever-menacing leading underscore!
6.
▲
by
nicolasgz
13y ago
Some relevant discussion here: http://cboard.cprogramming.com/cplusplus-programming/134827-...
7.
▲
by
nicolasgz
13y ago
Although I can't currently support my claim, I swear that I have gotten compiler warnings for doing so.
8.
▲
by
nicolasgz
13y ago
There are no rules to limit the kinds of member functions you can add to a struct. Structs can be polymorphic, can have vtables, and don't need to be compatible with C.