Language:EN
Pages: 10
Words: 1167
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
the erase and draw functions are declared virtual

Polymorphic Graphics System Assignment Answers

Your question:

student submitted image, transcription available below

student submitted image, transcription available below

student submitted image, transcription available below

student submitted image, transcription available below

Assignment Help Answers with Step-by-Step Explanation:

#include <cmath>

using namespace std;

    }

    void erase() const {

        erase();

        draw();

    void draw() const override {

        cout << "Drawing a circle." << endl;

};

class Triangle : public Figure {

    void erase() const override {

        cout << "Erasing a triangle." << endl;

    fig->draw();

}

    Triangle tri = new Triangle;

    fig = tri;

    // Testing with Circle

    Circle cir = new Circle;

    myDraw(cir);

    return 0;

b. With Virtual Functions:

In this part, the `erase` and `draw` functions are declared as virtual in the `Figure` class. This allows dynamic binding, and the correct version of the function is called based on the actual type of the object. The output will show that the derived class versions of `erase` and `draw` are called.

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : Justin Gonzalez

PageId: DOC03235C5