CS201J: Engineering Software, Fall 2002
|
Notes: Thursday 17 October 2002
Schedule Substitution
- Thursday, October 24: Problem Set 5: Part 1
- There will be no class on Thursday, October 24. You can drop off your PS5: Part 1 outside my office anytime before 5pm.
- Thursday, October 31: Problem Set 5: Part 2
MysteryType1 mt1; MysteryType2 mt2; MysteryType3 mt3; ... (anything could be here) mt1 = mt2.m (mt3);If the Java compiler is happy with this code, which of these are guaranteed to be true:
- The apparent type of mt2 is MysteryType2
- At the last statement, the actual type of mt2 is MysteryType2
- MysteryType2 has a method named m
- The MysteryType2.m method takes a parameter of type MysteryType3
- The MysteryType2.m method returns a subtype of MysteryType1
- After the last statement, the actual type of mt1 is MysteryType1
class A { public RA m (PA p) ; } class B extends A { public RB m (PB a); }Substitution Principle Eiffel Parameters PB >= PA PB <= PA Preconditions pre_A implies pre_B pre_B implies pre_A Result RB <= RA RB <= RA Postconditions post_B implies post_A post_B implies post_A#include <stdio.h> class A { public: void other () { printf("is an empty func in A\n"); }; virtual void other (class A *a) { printf("In A\n"); } }; class B: public A { public: void other (class B *b) { printf("In B\n"); } }; class C: public A { public: void other (class C *c) { printf("In C\n"); } }; void main(void) { A a; B b; C c; A *aPtr = &a; B *bPtr = &b; C *cPtr = &c; aPtr = bPtr; aPtr->other(bPtr); bPtr->other(); }
University of Virginia Department of Computer Science CS 201J: Engineering Software |
Sponsored by the National Science Foundation |
cs201j-staff@cs.virginia.edu |