RAD Studio
ContentsIndex
PreviousUpNext
Structure Member Declarations

The member-decl-list within the braces declares the types and names of the structure members using the declarator syntax shown in CodeGear C++ declaration syntax. 

A structure member can be of any type, with two exceptions 

The member type cannot be the same as the struct type being currently declared:

struct mystruct { mystruct s } s1, s2; // illegal

However, a member can be a pointer to the structure being declared, as in the following example:

struct mystruct { mystruct *ps } s1, s2; // OK

Also, a structure can contain previously defined structure types when declaring an instance of a declared structure. 

Except in C++, a member cannot have the type "function returning...," but the type "pointer to function returning..." is allowed. In C++, a struct can have member functions.

Note: You can omit the struct
keyword in C++.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!