nicolasgz·13 anni fa·discuss> you should always prefer private to protected and protected to publicIt'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 redundant: class X { public: stuff; private: other stuff; }; vs struct X { stuff; private: other stuff; }; > Another reason to use "class" is because it's OOP terminology. There's no notion of "struct" in OOPThat's cargo cult programming. Using "class" doesn't make your code OO. The language we are programming in is C++, not OOP.
nicolasgz·13 anni fa·discussEvery 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?
nicolasgz·13 anni fa·discuss> 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 article.
nicolasgz·13 anni fa·discussAlthough it should be possible per standard C++, Microsoft's compilers have trouble dealing with it.
nicolasgz·13 anni fa·discussSome relevant discussion here:http://cboard.cprogramming.com/cplusplus-programming/134827-...
nicolasgz·13 anni fa·discussAlthough I can't currently support my claim, I swear that I have gotten compiler warnings for doing so.
nicolasgz·13 anni fa·discussThere 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.
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 redundant:
vs
> Another reason to use "class" is because it's OOP terminology. There's no notion of "struct" in OOP
That's cargo cult programming. Using "class" doesn't make your code OO. The language we are programming in is C++, not OOP.