|
|
|
|
|
|
@abhishekm71 AFAIK, in C++, there are only static variables and static functions, but no static classes. |
static class blah {};
. Or is there? Even then, you might as well use a namespace instead of a "static class".
@abhishekm71 @vlad ok thanks, I understand your 1st and 3rd statement. Can you please elaborate on the second one? What are anonymous unions? |
5 A union of the form union { member-specification } ; is called an anonymous union; it defines an unnamed object of unnamed type. The member-specification of an anonymous union shall only define non-static data members. [ Note: Nested types and functions cannot be declared within an anonymous union. —end note ] The names of the members of an anonymous union shall be distinct from the names of any other entity in the scope in which the anonymous union is declared. For the purpose of name lookup, after the anonymous union definition, the members of the anonymous union are considered to have been defined in the scope in which the anonymous union is declared. [ Example: void f() { union { int a; const char* p; }; a = 1; p = "Jennifer"; } Here a and p are used like ordinary (nonmember) variables, but since they are union members they have the same address. —end example ] |
|
|
|
|
|
|