Introduction to OOP | Chapter 12: Implications of substitution: | next | previous | audio | real | text |
void Window::oops() { printf("Window oops\n"); } void TextWindow::oops() { printf("TextWindow oops %d\n", cursorLocation); TextWindow x; Window a; Window * b; TextWindow * c; a = x; a.oops(); // executes Window version b = &x; b->oops(); // executes TextWindow or Window version; c = &x; c->oops(); // executes TextWindow version