Menu

(Solved) : Use One Coord Classes Make Coord Inherit Color Class Library Includes Include Needed O Inc Q37272238 . . .

Use one of the Coord Classes and make Coord inherit theColor class

******************************************
* library includes
******************************************/
#include <iostream> // needed for I/O
#include <iomanip>
#include <cmath>
/******************************************
* pre-processor
******************************************/
#define PI 3.14159
using namespace std;

class Color
{
private:
       int* red;
       int* green;
       int* blue;
public:
// constructors
Color();
Color(int);
//the int is assigned to all three color data items
Color(int r, int g, int b);
//the 3 ints are assigned to the corresponding data items
//r into red, g into green, b into blue

// destructor
~Color();

// setters
       void setRed(int r)  {*red = r;}
       void setGreen(int g)  {*green = g;}
       void setBlue(int b)  {*blue = b;}
  
// getters
       int getRed() const  {return *red;}
       int getGreen() const  {return *green;}
       int getBlue() const  {return *blue;}
  
       void display();
};

// constructors
Color::Color()
{
   red = new int;
   green = new int;
   blue = new int;
  
   setRed(0);
   setGreen(0);
   setBlue(0);
}
Color::Color(int r)
{
   red = new int;
   green = new int;
   blue = new int;
  
   setRed(r);
   setGreen(r);
   setBlue(r);
}
Color::Color(int r, int g, int b)
{
   red = new int;
   green = new int;
   blue = new int;
  
   setRed(r);
   setGreen(g);
   setBlue(b);
}
// destructor
Color :: ~Color()
{
   delete red;
   delete green;
   delete blue;
}

// display function
void Color :: display()
   {
//blank line
       cout << “n”;
//Red is “the red data item”
       cout << getRed() << “is the red data itemn”;
//Green is “the Green data item”
       cout << getGreen() << “is the green data itemn”;
//Blue is “the Blue data item”
       cout << getBlue() << “is the blue data itemn”;
//blank line
       cout << “n”;
   }

Expert Answer


Answer to Use one of the Coord Classes and make Coord inherit the Color class ****************************************** * library…

OR