Question: What is wrong with the following code? Find (at least) five errors. For each error, state the line number , explain the error and show

What is wrong with the following code? Find (at least) five errors. For each error, state the line number , explain the error and show a correction.

#include

#include

using namespace std;

class colorCode

{

public:

void setRGB(int);

//accepts an int parameter and

//sets the RGB to the value of the parameter

void setName(string);

//accepts a string parameter and sets the name of the //object

//to the value of the parameter

string getName() const;

//returns the name of the object

int getRGB() const;

//returns the RGB of the object

void changeColor();

// adds 10 to the RGB value

private:

string name;

int RGB;

}

int main()

{

colorCode paintCans[10];

int i;

for (i = 0; i < 10; i++)

paintCans.setRGB[i] = 0;

paintCans[5].setName(GREEN);

paintCan[5].setRGB(192000);

cout << paintCans[5].getName << ' '

<< paintCans[5].getRGB() << endl;

return 0;

}

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 Databases Questions!