| Prev 14 | Data Abstraction | Chapter 2 section 14 + Chapter 11 | lab14 C/C++ ADTs |
| ** | Project Deadline Phase 2 | Phase 2 due in: changed EBNF and draft UML (10pts) | |
| 15 | OO Programming and Java | Chapter 2 section 17 + Java Handout + Chapter 12 | lab15 Java101 |
| Next 16 | Concurrency and Java | Chapter 13 not sect'n 8 | lab16 Java102 |
Try out this program: [ 15.cpp ]
Person * pointer;
Faculty dick;
pointer = & dick;
pointer->output(); // name and rank
Student jo;
pointer = &jo;
pointer->output(); // name and GPA
pointer = new Student(...);
pointer->output(); // name and GPA
Polymorphism in C++
C++ is a hybrid language. Polymorphism is an option.
The default is to cast objects. In other words to change the type of an object to a more abstract type. This can result in programs that have bugs.
If an object is assigned to another object of a more general (base) type, the specific data is stripped away. It behaves according to the general rules.
This happens with pass-by-value!
So in C++ always
. . . . . . . . . ( end of section Notes) <<Contents | End>>
Class Work
[ 15q.html ]
Lab Work
[ lab/15.html ]
Next
[ 16.html ]