Struct and class in C++

It is generally believed that struct is more suitable to be regarded as the realization of a data structure, and class is more suitable to be regarded as the realization of an object.
Difference
•The most essential difference is the default access control
1. The default inherited access permissions. The struct is public, and the class is private.
2. struct is the realization body of the data structure, its default data access control is public, and class as the object realization body, its default member variable access control is private.

Guess you like

Origin blog.csdn.net/it_xiangqiang/article/details/112978101