Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider the following extract from a program: 1 c l a s s Shape 2 { 3 public : 4 Shape ( ) ; 5
Consider the following extract from a program:
c l a s s Shape
public :
Shape ;
void s e t S i z e int ;
v i rtua l void draw ;
protected :
int s i z e ;
;
c l a s s Square : public Shape
public :
void draw ;
;
c l a s s Line : public Shape
public :
bool draw ;
;
a Waarom word draw in die Shape klas virtual verklaar? Wat beteken dit?
Why is draw in the Shape class declared virtual? What does it mean?
Skep vtable, maak polimorfisme moontlik, sodat basisklas pointer na afgeleide
klas objek afgeleide klas impl kan sien
b Watter draw implementering sou geroep word as n Shape pointer na n Square objek
gebruik word om draw te roep? Motiveer.
Which draw implementation would be called when a Shape pointer to a Square object
was used to call draw Motivate.
Afgeleide klas, virtual in basisklas en signature stem ooreen in afgeleide klas
c Watter draw implementering sou geroep word as n Shape pointer na n Line objek
gebruik word om draw te roep? Motiveer.
Which draw implementation would be called when a Shape pointer to a Line object
was used to call draw Motivate.
Geen: Basisklas is suiwer, geen impl, en afgeleide klas het nie n void draw
nie. Fout kom voor wanneer Line objek gemaak word.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started