Why don't people indent C++ access specifiers/case statements?

前端 未结 10 1691
悲哀的现实
悲哀的现实 2020-12-16 11:13

I often see stuff like this:

class SomeClass {
public:
    void someMethod();
private:
    int someMember;
};

This seems totally unnatural

10条回答
  •  再見小時候
    2020-12-16 11:40

    The access specifiers are really just labels (as in those used by goto). People generally don't indent labels, or outdent them one level wrt the surrounding code. So I would say this is not inconsistent at all.

    EDIT:

    The Standard also uses this style for access specifiers. Example from Chapter 10, paragraph 2:

    class Base {
    public:
      int a, b, c;
    };
    

提交回复
热议问题