Best practice: ordering of public/protected/private within the class definition?

后端 未结 10 1341
遥遥无期
遥遥无期 2020-12-12 14:34

I am starting a new project from the ground up and want it to be clean / have good coding standards. In what order do the seasoned developers on here like to lay things out

10条回答
  •  清歌不尽
    2020-12-12 14:53

    Personally I like to have public at top, protected and then private. The reason for this is that when somebody cracks open the header he/she sees what he/she can access first, then more details as he/she scrolls down.

    One should not have to look at the implementation details of a class in order to use it, then the class design is not done well.

提交回复
热议问题