referred to as either struct Account or simply Account. As another example, a three-dimensional Vector composite type that uses the floating point data type could be created with: struct Vector { float x; float y; float z; }; A variable named velocity with a Vector composite type would be declared as Vector velocity; Members of the velocity would be accessed using a dot notation. For example, velocity.x = 5; would set the x component of velocity equal to 5. Likewise, a color structure could be created using: struct Color { unsigned int red; unsigned int green; unsigned int blue; }; In 3D graphics, you usually must keep track of both the position and color of each vertex. One way to do this would be to create a Vertex composite type, using the previously created Vector and Color composite types: struct Vertex { Vector position; Color color; }; Instantiation Create a variable of type struct Vertex using the same format as before: Vertex v; Member access Assign values to the components of v like so: v.position.x = 0.0; v.position.y = 1.5; v.position.z = 0.0; v.color.red = 128; v.color.green = 0; v.color.blue = 255; Primitive subtype The primary use of struct is for the construction of complex datatypes, but sometimes it is used to create primitive structural subtyping. For example, since Standard C requires that if two structs have the same initial fields, those fields will be represented in the same way, the code struct ifoo_old_stub { long x, y; }; struct ifoo_version_42 { long x, y, z; char *name; long a, b, c; }; void operate_on_ifoo(struct ifoo_old_stub *); struct ifoo_version_42 s; . . . operate_on_ifoo(&s); will work correctly. Type signature Type signatures (or Function types) are constructed from primitive and composite types, and can serve as types themselves when constructing composite types: typedef struct { int x; int y; } Point; typedef double (*Metric) (Point p1, Point p2); typedef struct { Point centre; double radius; Metric metric; } Circle; See also Object composition struct (C programming language) Scalar (mathematics) References Data types Type theory Articles with example C code Articles with example C++ code