您的位置:首页 > 编程语言 > C语言/C++

c++构造函数

2016-03-15 14:13 232 查看
#include <iostream>
using namespace std;
class Point{
int x,y;
public:
***Point(int a,int b){}//:x(a),y(b){}// { x=a; y=b;}***
void MovePoint( int a, int b){ x+=a; y+=b;this->x+=a;cout<<"this="<<this<<endl;}
void print()
{
cout<<"x="<<x<<" "<<this->x<<"y="<<y<<" "<<this->y<<endl;
}

};

void main(){
Point point1( 10,10);
point1.MovePoint(2,2);
point1.print();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: