#include <iostream>
using namespace std;
class CPoint
{
public:
unsigned x;
unsigned y;
bool IsInCircle(CCircle *circle)
{
return (((x – circle->Center.x) * (x – circle->Center.x)
+ (y – circle->Center.y) * (y – circle->Center.y))
<= circle->Radius * circle->Radius);
}
};
class CCircle
{
public:
unsigned Radius;
CPoint Center;
};
int main()
{
return 0;
}
using namespace std;
class CPoint
{
public:
unsigned x;
unsigned y;
bool IsInCircle(CCircle *circle)
{
return (((x – circle->Center.x) * (x – circle->Center.x)
+ (y – circle->Center.y) * (y – circle->Center.y))
<= circle->Radius * circle->Radius);
}
};
class CCircle
{
public:
unsigned Radius;
CPoint Center;
};
int main()
{
return 0;
}
解决方案:40分
改一下顺序,原因是在CPoint编译时还不知道CCircle是什么东西
#include <iostream> using namespace std; class CCircle; class CPoint { public: unsigned x; unsigned y; bool IsInCircle(CCircle *circle); }; class CCircle { public: unsigned Radius; CPoint Center; }; bool CPoint::IsInCircle(CCircle *circle) { return (((x - circle->Center.x) * (x - circle->Center.x) + (y - circle->Center.y) * (y - circle->Center.y)) <= circle->Radius * circle->Radius); } int main() { return 0; }