• 5726阅读
  • 1回复

【提问】为什么和我想得到的结果不一样啊!!! [复制链接]

上一主题 下一主题
离线ratzip
 

只看楼主 倒序阅读 楼主  发表于: 2005-12-07
#include <iostream.h>
class point
{
public:
int x;
int y;
point(int a,int b)
{
  x=a;
  y=b;
}
void output()
{
  cout<<x<<endl<<y<<endl;
}
void output(int x,int y)
{
  x=x;
  y=y;
}
};
void main()
{
  point pt(3,3);
  pt.output(5,5);
  pt.output();
}


我想得到

5 5

结果是
3 3

为什么???
[ 此贴被XChinux在2005-12-07 22:38重新编辑 ]
BLOG: http://www.juntuan.cn/user1/999/index.shtml
离线XChinux

只看该作者 1楼 发表于: 2005-12-07
void output(int x,int y)
{
x=x;
y=y;
}
这句话,根本就没把this->x, this->y改了。
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
快速回复
限100 字节
 
上一个 下一个