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

前端 未结 10 1707
悲哀的现实
悲哀的现实 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:55

    Most editors Indent them automatically, for me i leave them as they are in small classes or small files or short switch statements but for long ones or long file with many long switch statements i use more indentation for easier readability

    I sometimes do this which i feel as old style

    Class CClass
        {
                CClass();
                ~CClass();
            Public:
                int a;
            Private:
                int b;
         };
    CClass::CClass
          {
               TODO code;
          }
    

    This sometimes make it easier when a file may contain more than 20 or 50 function so u can easily spot the beginning of every function

提交回复
热议问题