Answered step by step
Verified Expert Solution
Link Copied!

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:
1 c l a s s Shape
2{
3 public :
4 Shape () ;
5 void s e t S i z e ( int ) ;
6 v i rtua l void draw ()=0 ;
7 protected :
8 int s i z e ;
9} ;
10 c l a s s Square : public Shape
11{
12 public :
13 void draw () ;
14} ;
15 c l a s s Line : public Shape
16{
17 public :
18 bool draw () ;
19} ;
(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 (3)
(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 (4)
(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

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions