Skip to content

Last updated:2026-10-12

C++ struct vs class Differences

About the Author:

Personal WeChat official account:

wechat

About struct in C and C++, see All About struct

Generally speaking, a struct is better seen as the implementation body of a data structure, while a class is better seen as the implementation body of an object.

Differences:

The most essential difference is the default access control

The default inheritance access permission: for a struct it is public, for a class it is private.

As the implementation body of a data structure, a struct's default data access control is public, whereas as the implementation body of an object, a class's default member variable access control is private.

Comments