1 class Rectangle public virtual void set Widthdouble
(1) מלבן וריבוע – קוד class Rectangle { public: virtual void set. Width(double a. Width) {width= a. Width; } virtual void set. Height(double a. Height){height=a. Height; } double get. Height() const {return height; } double get. Width() const {return width; } private: double height; double width; }; 5 י' לויאן / תיכון תוכנה ד"ר ר' גלנט JCT אביב תשס"ה
(2) מרובע וריבוע – קוד class Square : Rectangle { public: void set. Width(double a. Width) { Rectangle: : set. Width(a. Width); Rectangle: : Set. Height(a. Width); } void set. Height(double a. Height) { Rectangle: : set. Width(a. Height); Rectangle: : Set. Height(a. Height); } }; 6 י' לויאן / תיכון תוכנה ד"ר ר' גלנט JCT אביב תשס"ה
Bounded and Unbounded Set template <class T> class Set { public: virtual void add(const T&)=0; virtual void delete_(const T&)=0; virtual bool is. Member(const T&) const=0; }; template <class T> void print. Set(const Set<T>& s) { for (iterator<T>i(s); i; i++) cout << (*i) << endl; } 11 י' לויאן / תיכון תוכנה ד"ר ר' גלנט JCT אביב תשס"ה
Persistent Set template <class T> void Persistent. Set: : add(const T& t) { // throw bad_cast Persistent. Object& p = dynamic_cast<Persitent. Object&>(t); its. Third. Party. Persistent. Set->add(p); } 13 י' לויאן / תיכון תוכנה ד"ר ר' גלנט JCT אביב תשס"ה
Bounded, Unbounded, Persistent Set Liskov Compliant 14 י' לויאן / תיכון תוכנה ד"ר ר' גלנט JCT אביב תשס"ה
Bounded, Unbounded, Persistent Set Liskov Compliant 15 י' לויאן / תיכון תוכנה ד"ר ר' גלנט JCT אביב תשס"ה
- Slides: 17