Assignment 10, due Nov 2

Part of the homework for 22C:60, Fall 2007
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Always, on every assignment, please write your name legibly as it appears on your University ID and on the class list! All assignments will be due at the start of class on the day indicated (usually a Friday). The only exceptions to this rule will be by advance arrangement unless there is what insurance companies call "an act of God" - something outside your control. Homework must be turned in on paper and in class! Late work may be turned in to the teaching assistant's mailbox, but see the late work policy. Never push late work under someone's door!

Homework

  1. Background: Your main program in Machine Problem 3 did some setup work and then called a subroutine you probably called GASKET. In your solution to MP3, this was probably in the same source file as your main program. Your main program did some setup work and then called GASKET. Here, think about dividing your source program into two files, one holding GASKET and the other holding everything else.

    a) Write a header file, gasket.h, to support calls to GASKET. (1/2 point)

    b) Write a main program that calls GASKET to print a gasket of height 8 with its lower left corner at line 10 column 22 in the display area -- obviously, this program won't work very well unless the display is at least 10 lines high by 38 characters wide. Your main program should, of course, use your header file to aid it in its call. (1/2 point)

  2. A problem: Write the implementation for vector add -- this is Chapter 10 exercise h. (1 point)

  3. Background: Suppose we adopt the convention that all objects of polymorphic classes begin with a tag field that points to the class descriptor for that class.

    a) Given that R3 and R4 contain pointers to objects, write code to transfer control to ELSE if the objects are in different classes, while falling through if they are in the same subclass. (2/5 point)

    b) The class descriptor is a record. Does it have any variable fields, or is the are all of its fields constants? (1/5 point)

    c) Based on your answer above, where should the class descriptor be defined, the class.a file, the class.h file? (2/5 point)