[CSI] nameless, complex and nested structures

Mikhail Nesterenko mikhail at cs.kent.edu
Fri Jul 16 23:44:10 EDT 2021


CSIB students,

So this is regarding today's discussion.
-- 
Mikhail


If a structure variable of one structure is used as a member variable
of another the terms are "complex structure" and "substructure"


// example structure
struct Example{
  int a;
  string b;
};

// complex structure
struct CompExample{
  int d;
  Example e; // substructure
};




It is legal to declare a structure variable without naming a
structure. Such structure is called "nameless":

struct {
  int a;
  string b;
} x, y;  // structure variables x and y of a nameless structure



It is also legal to define a structure inside another structure. Such
structure definitions are called "nested":


// nested structure example
struct Outer{
   struct Inner{
      int a;
      string b;
   };

   Inner c; // member variable of Outer structure of type Inner 
};



More information about the cs13001 mailing list