[C/C++] The difference between struct and class

The difference between struct and class


The default permissions are different

  • The default permission of struct is public public
  • The default permission of class is private private
  • Functions cannot be written in struct members, but function pointers can be written

If the access permission is not indicated in the class class, it is private by default and cannot be accessed outside the class

The struct can only be public, and can be accessed outside the class

Guess you like

Origin blog.csdn.net/weixin_45636061/article/details/125007769