c++对象和类部分习题

2025-04-27 23:05:06
推荐回答(2个)
回答1:

#include
#include
using namespace std;
class point
{
public:
point(float a,float b) { x=a; y=b; }
float Distance(point &p)
{
float dx=p.x - x;
float dy=p.y - y;
return (float)sqrt(dx*dx+dy*dy);
}
private:
float x,y;
};

void main()
{
point p1(2,3),p2(32,43);
cout<< p1.Distance(p2)<}

回答2:

谢谢你的题目我做完了,很简单的。