Question: In the following struct use a function pointer to switch to print each of draw functions based on the input for circle, rectangle and triangle

  1. In the following struct use a function pointer to switch to print each of draw functions based on the input for circle, rectangle and triangle respectively

struct GeoObject {

enum {CIR=0, REC, TRG} gCode;

union {

struct Cir { double x, y, r; }c;

struct Rec { double x, y, w, h; }r;

struct Trg { double x, y, b, h; }t;

};

};

void drawCir(struct GeoObject);

void drawRec(struct GeoObject);

void drawTrg(struct GeoObject);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!