| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 339 人关注过本帖
标题:[求助]下面调用函数有什么不同吗?
只看楼主 加入收藏
z_jzhao
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2007-9-29
收藏
 问题点数:0 回复次数:1 
[求助]下面调用函数有什么不同吗?
#include<iostream.h>
class point
{
public:
int x;
int y;
void init()
{
x=0;
y=0;
}
void output()
{
cout<<"x="<<x<<endl<<"y="<<y<<endl;
}
};
void main()
{
point pt;
pt.init(); //若用pt.init;语句则输出为负长整型数,pt.init()和pt.init用什么不同,为什么会这样?

pt.output();

};
搜索更多相关主题的帖子: 函数 
2007-09-29 15:01
刘军
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2007-9-24
收藏
得分:0 
pt.init() 能调用类的方法
pt.init;会有一个警告 为什么不是一个错误
#include<iostream.h>
#include<stdio.h>
class point
{
public:
int x;
int y;
void init()
{
x=0;
y=0;
}
void output()
{
cout<<"x="<<x<<endl<<"y="<<y<<endl;
}
};
void main()
{
point pt;
pt.init; //若用pt.init;语句则输出为负长整型数,pt.init()和pt.init用什么不同,为什么会这样?
printf("%d\n",&pt.x);
printf("%d\n",&pt.y);
printf("%d\n",pt.init);
printf("%d\n",pt.output);
pt.output();

}
运行上述代码,你就知道有什么区别了
2007-10-01 03:18
快速回复:[求助]下面调用函数有什么不同吗?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011382 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved