Придумал. Использую обычные указатели, а с помощью адресной арифметики буду выводить значения
class Figure {
public:
Figure(bool * figure, string name) : figure(figure), name(name) {
Rotation rotation{ this->figure };
rotation.show();
this->show_figure();
cout << this->figure << "\n";
};
class Rotation {
public:
Rotation(bool * figure) {
this->figure = figure;
cout << this->figure << "\n";
};
enum class rotate_sides { Normal = 0, Degree90 = 1, Degree180 = 2, Degree270 = 3 };
void show() {
bool* p = this->figure;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
cout << *(p++) << " ";
}
cout << "\n";
}
}
private:
bool * figure;
};
void rotate_figure() {
switch (side) {
case Rotation::rotate_sides::Normal:
this->side = Rotation::rotate_sides::Degree90;
break;
case Rotation::rotate_sides::Degree90:
this->side = Rotation::rotate_sides::Degree180;
break;
case Rotation::rotate_sides::Degree180:
this->side = Rotation::rotate_sides::Degree270;
break;
case Rotation::rotate_sides::Degree270:
this->side = Rotation::rotate_sides::Normal;
break;
}
cout << static_cast<int>(side) << "\n";
}
void rotate_figure(Rotation::rotate_sides side) {
this->side = side;
}
void show_figure() {
bool* p = this->figure;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
cout << *(p++) << " ";
}
cout << "\n";
}
}
protected:
bool * figure;
bool figure_sided[4][4];
static Rotation::rotate_sides side;
string name;
};
Figure::Rotation::rotate_sides Figure::side = Figure::Rotation::rotate_sides::Normal;
class Box : public Figure {
private:
static bool box[4][4];
public:
Box() : Figure(*box, "Box") {
cout << box << "\n";
};
};
bool Box::box[4][4] = {
{0, 0, 0, 0},
{0, 1, 1, 0},
{0, 1, 1, 0},
{0, 0, 0, 0},
};