#include <iostream.h>
class point
{
public:
int x;
int y;
point(int a,int b)
{
x=a;
y=b;
}
void output(int x1,int y1)
{
x=x1;
y=y1;
cout<<x<<","<<y;
}
};
void main()
{
point pt(3,3);
pt.output(5,5);
}你的上面的参数赋值不正确
或者这样也可:
#include <iostream.h>
class point
{
public:
int x;
int y;
point(int a,int b)
{
x=a;
y=b;
}
void output()
{
cout<<x<<","<<y;
}
void output(int x1,int y1)
{
x=x1;
y=y1;
}
};
void main()
{
point pt(3,3);
pt.output(5,5);
pt.output();
}但是这样效率不高,而且多余