Can there be two public section in a class? If yes then why ? And in which circumstances we do so?

前端 未结 6 499
北恋
北恋 2020-12-25 15:43

There is something bugging me about classes. For example

class A
{
public:
  A()
  {
  .....
  .....
  }

  void cleanup()
  {
  ....
  ....
  ....
  }

publ         


        
6条回答
  •  伪装坚强ぢ
    2020-12-25 15:58

    Yes its correct however personally I prefer to just have one public section at the top of the class, that's where programmers looks first when examining a new class. It is then easier to see which parts are supposed to be accessible and which are not -- instead of browsing the whole class header.

提交回复
热议问题