← Back to Streams
Question 624
operator<< for a Color
operator<< for a Color
A structRgbwith three public intsr,g,bis given. Complete the free functionostream& operator<<(ostream& os, const Rgb& c)so that a color prints asrgb(, the three values separated by a comma and a space, then). Do not print a newline; returnos. Output ofRgb red{255, 0, 0}; cout << red << "\n";(see Expected Output). Do NOT write a main function.
Expected Output:
rgb(255, 0, 0) [rgb(10, 20, 30)]
= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
Streamsostream
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.