码迷,mamicode.com
首页 > 移动开发 > 详细

移动点的坐标

时间:2016-04-09 18:50:42      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:

#include "stdafx.h"
#include "iostream"

using namespace std;

class Point
{
public:
Point(double x,double y);
~Point();
//获得类的成员变量_x的值
double GetX()const{ return _x; }
//获得类的成员变量_y的值
double GetY()const { return _y; }
//点的坐标(_x,_y)移动
void Move(double xOff, double yOff)
{
_x += xOff, _y += yOff;
}
private:
double _x, _y;
};

Point::Point(double x, double y):_x(x), _y(y)
{
}

Point::~Point()
{
}

int _tmain()
{
Point pt(1.5, 2.5);
pt.Move(2.5, 1.5);
//“Point::GetX”: 函数调用缺少参数列表;请使用“&Point::GetX”创建指向成员的指针
cout << ‘(‘ << pt.GetX() << ‘,‘ << pt.GetY() << endl;
return 0;
}

移动点的坐标

标签:

原文地址:http://www.cnblogs.com/huninglei/p/5372247.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!