编程异常吧 关注:1贴子:24
  • 0回复贴,共1

C++_this指针

只看楼主收藏回复

#include <iostream>
using namespace std;
class CPoint{
public:
int cx;
int cy;
CPoint()
{
cx = 0;
cy = 0;
}
CPoint(int a, int b)
{
cx = a;
cy = b;
}
void input(int cx, int cy)
{
this->cx = cx;
this->cy = cy;
}
//上下俩函数的不同之处
/*
void input(int cx, int cy)
{
cx = cx;
cy = cy;
}
*/
void coutput()
{
cout << cx << endl << cy << endl;
}
};
int main()
{
CPoint cp(5,5);
cp.input(10,10);
cp.coutput();
return 0;
}


1楼2014-08-12 22:01回复