C ++ - only difference between the classes and class structure struct

The only difference: Different default access permissions, the other does not make any difference.

class Base { / * ** * / };
 class D1: Base { / * ** * / }; // default D1 is public inheritance of Base 
struct D2: Base { / * ** * / }; // default D2 Base is the inheritance of private

Recommendation: whether class or struct inheritance, explicitly declared inheritance, to avoid misunderstanding.

Guess you like

Origin www.cnblogs.com/yrm1160029237/p/11617092.html