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();
}
运行上述代码,你就知道有什么区别了