注意:这篇文章上次更新于1443天前,文章内容可能已经过时。
This article was last updated1443 days ago, the content may be outdated.
C++ 中的结构体对 C 语言的结构体进行了武装,和类几乎没有什么区别,唯一区别在于C++中结构体内成员默认访问属性是 public 的,而 class 中的成员默认访问权限是 private 的。
那么要如何才能在 C 语言的结构体中定义私有成员呢?
直接看代码吧。
In C++, structs have been fortified compared with their C counterparts, and are almost no different from classes. The only difference is that members inside a C++ struct are public by default, while members of a class are private by default.
So how can we define private members in a C struct?
Let’s just look at the code.
1 | // 声明一个空的结构体,只有一个空类型指针占位。 |


