As the word aggregation itself implies aggregation types are composed from other types.
In C aggregation types are array and structure types.
Take into account that an aggregation type can include another aggregation type.
Here is an example of aggregation types
#include <stdio.h>
int main( void )
{
struct TLine
{
struct TPoint
{
int x;
int y;
} first, second;
} lines[10] = { [0] = { { 0, 0 }, { 10, 10 } } };
printf( "lines[%d].first = { %d, %d }, lines[%d].second = { %d, %d }\n",
0, lines[0].first.x, lines[0].first.y,
0, lines[0].second.x, lines[0].second.y );
}
The program output is
lines[0].first = { 0, 0 }, lines[0].second = { 10, 10 }
The structure TLine
is an aggregation type that contains another aggregation type definition struct TPoint
. And lines
is an object of one more aggrefation type - array of TLines.