Starting from:

$29.99

ECE 39595 Homework 6

HW 6 – Casts
The provided program is an illegal C++ program. C++ cannot always tell when a program is illegal, and in
that case, it will compile the program but the behavior will be undefined and dependent on the
combination of the processor, OS, compiler and so forth. What is done in this program should never be
done by you.
VFTs for the different classes are provided in a .pdf called VFT.pdf. Label VFT entries with the statement
number (shown in the code, S1 through S5) of the call(s) in main.cpp that use them. The S0 call is shown
as an example. You may do your drawings by hand and scan or photograph the sheet to turn in. Note
any strange behavior and explain it to yourself in terms of the VFTs, but you don’t need to write this and
turn it in.
Make a different copy of main.cpp called mainStaticCast.cpp and mainDynamicCast.cpp and turn the Cstyle casts into static_cast and dynamic_cast, respectively. Observe how all of the illegal assignments in
the original program are disallowed with dynamic_cast, and some are disallowed with static_cast.
What to turn in:
Turn in a directory named after your userid. In a subdirectory named 1, put the answers for Part 1 in
this. It can be photographs or one or more .pdf files. In a subdirectory named 2 put the code using
static_cast and dynamic_cast. Note that only the file with the main function changes. It is expected that
the code in directory 2 will have compile time or run time errors caused by the casts.
Zip up the director and turn it into Brightspace.
Grading:
4 points for the VFT
3 points for showing what entries are used by statements
3 points for programs using dynamic and static casts

More products