C++ style guide: Difference between revisions

Jump to navigation Jump to search
280 bytes added ,  6 September 2021
Add separator recommendation between member functions and variables.
(New "class declarations" section)
(Add separator recommendation between member functions and variables.)
(8 intermediate revisions by the same user not shown)
Line 97: Line 97:
=== Class declarations ===
=== Class declarations ===


The access specifier ({{codeline|public:}}, {{codeline|protected:}}, {{codeline|private:}}) should always be stated rather than relying on the C++ language defaults for a particular object (for example, {{codeline|class = private}}).
The access specifier ({{codeline|public}}, {{codeline|protected}}, {{codeline|private}}) should always be stated rather than relying on the C++ language defaults for a particular object (for example, "{{codeline|class}}" = "{{codeline|private}}").


Within a class the different access blocks should appear in the order 1) public, 2) protected, 3) private.
Within a class, the different access blocks should appear in the order 1) {{codeline|public}}, 2) {{codeline|protected}}, 3) {{codeline|private}}.


Within an access block, member functions should be specified before member variables.  If there are both member functions and member variables use
    //--------
between the sections to visually separate the two categories.


=== Namespace ===
=== Namespace ===
1,072

edits

Navigation menu