- 论坛徽章:
- 17
|
回复 1# homerzhou
C++中类可以由三个关健字生成class,struct,union,C++充许有不具名类以及不具名的类成员。当访问不具名类的成员时可以从最外层具名的类型处直接访问。
相关规定如下:
Unnamed classes and classes contained directly or indirectly within unnamed classes
shall not contain static data members
对于联合体的成员访问又有如下规定,由于common initial sequence所以访问的值是相同的。
If a POD-union contains two or more POD-structs that share a common initial sequence, and if the PODunion
object currently contains one of these POD-structs, it is permitted to inspect the common initial part
of any of them. Two POD-structs share a common initial sequence if corresponding members have layoutcompatible
types (and, for bit-fields, the same widths) for a sequence of one or more initial members.
|
|