- 論壇徽章:
- 17
|
回復(fù) 1# homerzhou
C++中類可以由三個關(guān)健字生成class,struct,union,C++充許有不具名類以及不具名的類成員。當(dāng)訪問不具名類的成員時可以從最外層具名的類型處直接訪問。
相關(guān)規(guī)定如下:
Unnamed classes and classes contained directly or indirectly within unnamed classes
shall not contain static data members
對于聯(lián)合體的成員訪問又有如下規(guī)定,由于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.
|
|