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

前端 未结 6 516
北恋
北恋 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 16:02

    Access qualifiers simply apply to the code that follows until the next qualifier. There is no restriction on the number or order of such qualifiers.

    It is generally not necessary to repeat the same access qualifier in a class, and doing so is likely to confuse the reader. They also may have an effect on the layout of a class, since data members following the same qualifier must be laid out in the order they are declared, but there is no such restriction between qualifiers.

提交回复
热议问题