вот (+)
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено DASM 12 марта 2005 г. 21:43
В ответ на: а по сути - речь похоже об анонимных объединениях, причем в стиле С++, т.к. не имеет тэга. Вынужден разочаровать - подобные union должны быть статическимим и extern ну никак объявлены ну никак не могут отправлено DASM 12 марта 2005 г. 21:42


Anonymous unions are unions that are declared without a class-name or declarator-list.

union { member-list }
Such union declarations do not declare types — they declare objects. The names declared in an anonymous union cannot conflict with other names declared in the same scope.

In C, an anonymous union can have a tag; it cannot have declarators.

Names declared in an anonymous union are used directly, like nonmember variables.

Example
// anonymous_unions.cpp
// compile with: /EHsc
#include

using namespace std;
int main()
{
union
{
double d;
char *f;
};

double c = 3.3;
char *e = "outside of union";

d = 4.4;
f = "inside of union";

cout << c << ' ' << d << endl;
cout << e << endl << f << endl;
}
Output
3.3 4.4
outside of union
inside of union
In addition to the restrictions listed in Union Member Data, anonymous unions are subject to additional restrictions:

They must also be declared as static if declared in file scope. If declared in local scope, they must be static or automatic.
They can have only public members; private and protected members in anonymous unions generate errors.
They cannot have function members.
Note Simply omitting the class-name portion of the syntax does not make a union an anonymous union. For a union to qualify as an anonymous union, the declaration must not declare an object.


Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru