ITPub博客

首页 > > > 编程新手想问各路大神下面程序哪里有问题,为什么结果是一个奇葩数?

编程新手想问各路大神下面程序哪里有问题,为什么结果是一个奇葩数?

作者:dapan 时间:2019-09-04 15:25:55 0 删除 编辑
#include<iostream>
using namespace std;
class point
{
public:
    point(double a, double b,double c,double d);
    friend void dist(point*p);
    void show();
private:
    double u;
    double w;
    double x;
    double y;
    double z;
};
point::point(double a, double b, double c, double d )
{
    u = a;
    w = b;
    x = c;
    y = d;
}
void dist(point*p)
{
    p->z=sqrt((p->u -p->x)*(p->u -p-> x)+(p->w -p->y)*(p->w -p->y));
    
}
void point::show()
{
    cout << "the distance of the two point is:" << z << endl;
}
int main()
{
    point chih(8,6,4,2);
    point *p;
    p = &chih;
    chih. show();
}


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/758/viewspace-3120091/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2020-08-07

  • 博文量
    4504
  • 访问量
    87236