In this exercise, we are going to take our structs and, based on the fact they introduce a new data type
in the language, use them everywhere we have been using elementary data types;
As parameters to functions
As return values
As elements of an array
As elements of a dynamically allocated array
Then only, we will examine how they might be used as "pseudo-classes".
This first exercise will illustrate how we may manipulate arrays of struct elements.
You will see that everything we learned about arrays still applies and what you read about structs nicely integrates with it.
Beyond using structs as a new data type, which may therefore be leverage in arrays and dynamical arrays by the use of pointers,
it is also frequent to use structs to represent a new type of application-domain's "object".
This is very similar to the ideas you've been already exposed to in languages such as Java or C++ when dealing with Classes
and their Instances.
Unlike real object-oriented languages, we do not have the luxury of packing together functions and structs.
Instead, we may write a struct representing the data-aspect of things and then write a bunch of functions,
each taking as first parameter an instance of such a struct. If we name this first parameter "this" some of you might see better
how it relates to what C++ does auto-magically for you.
Regardless of such efforts, we are not using an object oriented languages so we won't be able to get polymorphism or inheritance.
This, however, doesn't mean we should not structure our projects in a rationale and even "objects-like" manner.
This folder will show you how it is done in an exercise meant to define a new type of "objects" - re-sizable arrays of ints.
This video should help you visualize the data structure used in PA301, give you an idea of how
you may trace through your work more easily, and give you a head start on both the dictionary_build and dictionary_free functions.