Show: Object Pascal C++
Display Preferences

struct

From Appmethod Topics
Jump to: navigation, search

Go Up to Keywords, Alphabetical Listing Index


Category

Type Specifiers

Syntax

struct [<struct type name>] {
[<type> <variable-name[, variable-name, ...]>] ;
    .
    .
    .
} [<structure variables>] ;

Description

Use a struct to group variables into a single record.

<struct type name> An optional tag name that refers to the structure type.

<structure variables> The data definitions, also optional.

Though both <struct type name> and <structure variables> are optional, one of the two must appear.

You define elements in the record by naming a <type>, followed by one or more <variable-name> (separated by commas).

Separate different variable types by a semicolon.

Use the . operator, or the -> operator to access elements in a structure.

To declare additional variables of the same type, use the keyword struct followed by the <struct type name>, followed by the variable names. In C++ the keyword struct can be omitted.

Note: The compiler allows the use of anonymous struct embedded within another structure.

See Also

Code Samples

Personal tools
In other languages