我有一个我正在尝试使用的基本文件。
#ifndef POINT_GUARD
#define POINT_GUARD
//------------------------------------------------------------------------------
struct Point {
int x, y;
Point(int xx, int yy) : x(xx), y(yy) { }
Point() :x(0), y(0) { }
};
//------------------------------------------------------------------------------
inline bool operator==(Point a, Point b) { return a.x==b.x && a.y==b.y; }
//------------------------------------------------------------------------------
inline bool operator!=(Point a, Point b) { return !(a==b); }
//------------------------------------------------------------------------------
#endif // POINT_GUARD
请注意,它被包裹在防护罩中。现在这被导入到两个不同的文件中。不过,我遇到了一个错误。
它一碰到它就会抱怨struct Point
它是“点的重新定义”。有什么想法可以在这里发生吗?