















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
















Structures
docsity.com
docsity.com
The first thing we have to know is that a datastructure creates a new type:
Once a data structure is declared, a new typewith the identifier specified as structure_nameis created and can be used in the rest of theprogram as if it was any other type. Forexample:
docsity.com
docsity.com
It is important to clearly differentiate betweenwhat is the
structure type name
, and what is
an object
(variable) that has this structure
type.
We can instantiate many objects (i.e. variables,
like apple, banana and melon) from a singlestructure type (product).
docsity.com
Once we have declared our three objects of adetermined structure type (apple, banana andmelon) we can operate directly with theirmembers.
To do that we use a dot (.) inserted betweenthe object name and the member name.
docsity.com
Let's see a real example where you can see howa structure type can be used in the same way asfundamental types:
docsity.com
docsity.com
Therefore, one of the most importantadvantages of data structures is that we caneither refer to their members individually or tothe entire structure as a block with only oneidentifier.
Data structures are a feature that can be usedto represent databases, especially if we considerthe possibility of building arrays of them.
docsity.com
Structures
docsity.com
docsity.com
docsity.com
docsity.com
docsity.com