Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Class RgbColor stores a color in RGB format. It is different from struct Rgb as it has member functions and will be part of a

Class RgbColor stores a color in RGB format. It is different from struct Rgb as it has member functions and will be part of a class hierarchy. Do the following: Make RgbColor a derived class of Color. Change provided member function getRgb() so that it overrides the base class version of the function. Inside the function definition of rangeComponent(), remove the if-else and instead call the base class version of the rangeComponent() function with a min of 0 and max of 255 (do not change the RgbColor constructor).

Relevant Code:

// RgbColor class definition for objects that represent a color // made of 1-byte red, green, and blue components. class RgbColor { public: // Initialize color to red, green, blue components specified. RgbColor(int initRed, int initinitGreen, int initBlue);

// Convert color to RGB (trivial). void getRgb(int& red, int& green, int& blue) const;

private: int red, green, blue;

// Keep component in proper range. static void rangeComponent(int& component); };

// Definitions

RgbColor::RgbColor(int initRed, int initGreen, int initBlue) : red(initRed), green(initGreen), blue(initBlue) // initialize components { // Ensure components in proper range. rangeComponent(red); rangeComponent(green); rangeComponent(blue); }

void RgbColor::rangeComponent(int& component) { if (component < 0) component = 0; else if (component > 255) component = 255; }

// let me know if there is any code you feel is missing/would need to help in solving this

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Sql++ For Sql Users A Tutorial

Authors: Don Chamberlin

1st Edition

0692184503, 978-0692184509

More Books

Students also viewed these Databases questions

Question

3. Outline the four major approaches to informative speeches

Answered: 1 week ago

Question

4. Employ strategies to make your audience hungry for information

Answered: 1 week ago