While a designing a C++ class, we need to follow some coding standards. Any C++ class follows some naming rules,some declaration order,etc.

  1. Declare a class with order : public members -> protected members -> private members,while declaration and definition.
  2. Make data members private and provide access to them through inline public getter/setter functions if needed.
    (This breaks the data abstraction paradigm of OOP. So,use getter/setter only when necessarily required like validation,do something else with variable,etc)
  3. In each section, the declaration should have the following order.
    Typedefs and Enums
    Methods including static methods
    Data members.
  4. Friend declaration should always be private.