Declaring Structure Types

Enumeration types are useful, but there are more powerful types you can declare, called structure types.

Structure types let you bundle up a set of member variables into a single variable. Then you can keep related data together in a single package and pass it around just as you pass an int or a char. You can even make an array of structures.

A structure type is declared with keyword struct, a name, and any number of typed members:

struct typename
{
   type membervariablename...
} ;

Here's an example:

struct aTapeElement
{
   char Operator;
   float Operand;
} ;

Get SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.