SLIDE 1
CS ¡162 ¡ Intro ¡to ¡Programming ¡II ¡
Polymorphism ¡Ia ¡
1 ¡
CS 162 Intro to Programming II Polymorphism Ia 1 - - PowerPoint PPT Presentation
CS 162 Intro to Programming II Polymorphism Ia 1 Virtual Func:ons A pointer to a derived (child) class is type- compa:ble with a pointer to
1 ¡
Wizard *w1 = new Wizard(“Larry",100, 20,10,100); Character *c1 = w1;
2 ¡
3 ¡
4 ¡
¡
5 ¡
6 ¡
¡
/* Character.hpp */ class Character { Public: Virtual void attack(Character& c); /* … */ }
7 ¡
8 ¡
9 ¡
10 ¡
¡
/* Character.hpp */ class Character { Public: Virtual void attack(Character& c); /* … */ }
11 ¡
12 ¡
13 ¡