小编Eoi*_*gan的帖子

C++ 创建一个函数来获取两点之间的距离

在我的程序中,我创建了一个Point用两个值调用的构造函数。我还有一个set, get,scaletranslate函数。我正在尝试创建一个函数,使我能够获取对象与另一个点之间的距离。我遇到了麻烦,但任何帮助都会很棒。

#ifndef POINTMODEL
#define POINTMODEL
#define POINTDEB UG

#include <iostream>
#include <string.h>

using namespace std;

class Point {
public:
    Point(void);
    Point(double anX, double aY);
    ~Point();

    void setPoint(double anX, double aY);

    double getX();
    double getY();

    double scaleX(double theX);
    double scaleY(double theY);
    void translate(double theX, double theY);

    void distance(const Point& aPoint);

protected:
private:
    double theX;
    double theY;
};

inline Point::Point(void)
{
    theX = 1;
    theY = 1;
    cout << "\n The default …
Run Code Online (Sandbox Code Playgroud)

c++ function distance object

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

c++ ×1

distance ×1

function ×1

object ×1