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


there bugging me classes. example

class { public:   a()   {   .....   .....   }    void cleanup()   {   ....   ....   ....   }  public:   uint a;   ulong b; }; 

in above example there 2 public section. in first section defining constructor , method , in second section declaring data members. above class i.e. correct. can that? if yes why needed , in circumstances should use it? since can entire thing in 1 section why there 2 sections?

access qualifiers apply code follows until next qualifier. there no restriction on number or order of such qualifiers.

it not necessary repeat same access qualifier in class, , doing confuse reader. may have effect on layout of class, since data members following same qualifier must laid out in order declared, there no such restriction between qualifiers.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -