Skip to content

Style: Consider using trailing underscores for protected/private attributes and methods in C++ #398

@arcondello

Description

@arcondello

Currently we follow Google's C++ Style guide and use trailing underscores for protected/private attributes

class A {
 public:
    void a_method();
    int a;
 protected:
    void b_method();
    int b_;
 private:
    void c_method();
    int c_;
};

I propose that we switch to using leading underscores for both attributes and methods in our C++ code base.

class A {
 public:
    void a_method();
    int a;
 protected:
    void _b_method();
    int _b;
 private:
    void _c_method();
    int _c;
};

Alternatives

Use trailing underscores for both methods and attributes. This would be more C++-y and less Pythonic, but IMO less readable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested or further design needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions