Lab #1: CDT, ADT and PolymorphismIntroductionThis lab is split into four parts. The first part concentrates on getting familiarized with the construction of concrete data types (CDT). The second part examines ADTs (abstract data types). And the third part deals with polymorphic code. Finally, the fourth part delves into objects. Both the latter two parts are optional.Software Setup
1. Concrete Data Types (CDT)CDTs are data types that the concrete data representations are transparent. In this problem, we'd like to experience with CDT via one example: theComplex_t data type. Download
this program to start with (complex.h, complex.c ).
First compile the code we offered you by a simple makeyou may see a bunch of "make" messages and then an executable a.exe
should be generated.
Run the executable ############################################################# @@ TODO: fill in your code. @@ in file: "complex.c", function: "Complex_subTraced" @@ at line: 51 #############################################################Open the file complex.c , it's clear what code you should modify
or supply. Feel free to add any
new functions to this file and the header file complex.h .
After finishing the task, try to modify the client code in file
User-level tracing: It's very nice and convenient to be able to trace the code at runtime. The code we offered you has been instrumented with this facility. To see how the debugger works, you may try to run this command: a -trace @ -debug 3to trace your code. Finally, try to run a -hto see other informations.
How this debugger works? You may firstly want to study 2. Abstract Data Types (ADT)ADTs are data types that the concrete data representations are opaque. In this problem, we'd like to experience with ADT by rethinking our previous example: theComplex_t
data type. Download this program to start with
(again complex.h, complex.c ).
As last problem, your job is to substitute What's the difference between CDT and ADT? Can we access data representations directly in ADTs? Write some code to justity your conclusions.
3. PolymorphismIn this problem, your job is to implement the polymorphic data typeTuple_t as we discussed in class.
Download this program
to start with.
The newly added files are
We have suppied, in file
Question #1: How can we generalize the |