Anonymous
Неожиданная ошибка перевода и сегментации при работе с std :: массива объектов
Сообщение
Anonymous » 30 июл 2025, 21:38
Я кодирую программу о формах, и у меня возникают проблемы с тем, что перечисление правильно печатает. Вот код: < /p>
shape.h:
Код: Выделить всё
struct Point{int x; int y;};
enum class Color{
NO_COLOR = 0,
BLUE,
YELLOW,
RED,
GREEN
};
class Shape {
public:
char id;
Color shapeColor;
Shape(char id, Color C): id(id), shapeColor(C) {};
bool operator==(Shape otherShape) {
return (this->id == otherShape.id && this->shapeColor == otherShape.shapeColor);
}
}
< /code>
main.cpp:
bool solve(Shape shape, const std::array& blueShapes, const std::array& yellowShapes, const std::array& redShapes, const std::array& greenShapes,
const std::array& board, const std::array& colorBoard, Point currCoord = {0, 0}, int numSqRem = 400) {
iterNum++; std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79720398/unexpected-enum-print-and-segmentation-fault-when-dealing-with-an-stdarray-of[/url]
1753900715
Anonymous
Я кодирую программу о формах, и у меня возникают проблемы с тем, что перечисление правильно печатает. Вот код: < /p> shape.h: [code]struct Point{int x; int y;}; enum class Color{ NO_COLOR = 0, BLUE, YELLOW, RED, GREEN }; class Shape { public: char id; Color shapeColor; Shape(char id, Color C): id(id), shapeColor(C) {}; bool operator==(Shape otherShape) { return (this->id == otherShape.id && this->shapeColor == otherShape.shapeColor); } } < /code> main.cpp: bool solve(Shape shape, const std::array& blueShapes, const std::array& yellowShapes, const std::array& redShapes, const std::array& greenShapes, const std::array& board, const std::array& colorBoard, Point currCoord = {0, 0}, int numSqRem = 400) { iterNum++; std::cout Подробнее здесь: [url]https://stackoverflow.com/questions/79720398/unexpected-enum-print-and-segmentation-fault-when-dealing-with-an-stdarray-of[/url]