CS246 Lecture Notes - Lecture 18: Decorator Pattern, Unified Modeling Language

110 views2 pages

Document Summary

You have an existing object, you want to add some features/functionality to this object. Abswindow *w = new basicwindow(); w = new scroll (w); w = new menu(w); Uml diagram of the decorator pattern was taken by the phone camera. Do not use casting unless you really have to. Node n; int *p = (int *) &n; cout << *p << endl; // this might actually print data field depending on the compiler. // that is if the data field was presented first. If your compiler presented the nullptr first, this will terminate the program. [a template function is a function with a type paramater- the type you want to cast to] static_cast. This is known as a sensible cast - a cast where the conversion/meaning is well-defined. 2 void foo(int x) { } void foo(double x) { } 9 double a = //something; foo(a); // calls foo(double) // we want to call foo(int) using a foo(static_cast(a)); // calls foo(int)

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents