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

前端 未结 6 512
北恋
北恋 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:11

    As @Marcelo Cantos's answer explains, this is allowed. When writing code yourself you should avoid this, as it only leads to confusion when others read your code. The only place I have ever seen this in real life is in the code generated by various MFC-wizards. Whenever you add some thing to your class using a wizard, it would just add an extra section to the end of your class.

提交回复
热议问题