DataStructures Series #2 – Composite Datatype

Originally posted on my medium page: https://medium.com/@otarutunde

Composite Datatype

A composite datatype is a datatype which can be constructed with the programming language primitive datatypes and other composite datatypes.

An example would be struct in C/C++:

The struct datatype in c/c++ composes of a fixed set of primitive and/or other composite datatypes.

For example:

struct Account {
int account_number;
char *first_name;
char *last_name;
float balance;
};

This composite datatype Account when created, tells the compiler to create a memory block with a size equal to the sum size of its individual data types.

You can check for other composite types in other programming languages too.

We can create even more complex composite datatypes by having an already created composite datatype as a field in another composite datatype as shown below:

struct Deposits {    char *from_name;    Account to_account };

REFERENCES: