Object relationship

18.3 - Composition


Composition is used to create a more complex object from simpler objects. For example, we can compose a fraction from a numerator and a denominator. Both the numerator and denominator belongs to the fraction object. Another examples include a Pokemon having its stats, ability, and moves; or alternatively an animal having its name, science name, and taxonomy.

Your task is to create two classes, the first one is Color, which contain three unsigned char members called r, g, and b. All of them should be public. The next class is called Tetromino, which is composed of a Color object called color and a char called letter.

Note: the members of Color and Tetromino should be public.

class Color { // Define the Color class here. }; class Tetromino { // Define the Tetromino class here. };