I am trying to use a set method to apply 7 colors to an array in c++. I am not entirely sure how to use the setElement method in my main function to help me append colors to the indices in my array, as I cannot find any help online or in my book. So far, I have:
#include <iostream>
#include <string>
using namespace std;
class randColor
{
private:
string colors[7];
public:
void setElement(index, "color")
{
colors[] = index;
index = "color";
}
void printColor()
{
int i = 0;
for(i = 0; i <= 7; i++)
{
cout << colors[i] << endl;
}
}
};
int main()
{
randColor RandomOne;
RandomOne.setElement(index, {"red", "orange", "yellow", "blue", "green", "indigo", "violet"});
RandomOne.printColor();
return 0;
}