设计了一个坐标的实验。。。
#include <iostream>
using namespace std;
class point
{
public:
point(int my_x, int my_y, int my_z);
point()
{
x = 0;
y = 0;
z = 0;
}
void tellmeyourpoint(int your_x = 1, int your_y = 1, int your_z = 1);
void showpoint()
{
cout<<x<<","<<y<<","<<z<<endl;
}
~point()
{
cout<<"OK"<<endl;
}
private:
int x;
int y;
int z;
};
point::point(int my_x, int my_y, int my_z)
{
x = my_x;
y = my_y;
z = my_z;
}
void point::tellmeyourpoint(int your_x, int your_y, int your_z)
{
x = your_x;
y = your_y;
z = your_z;
}
int main()
{
point P(6, 6, 6);
P.showpoint();//P调用有参构造函数
point PP;
PP.showpoint();//PP调用无参构造函数
int yx, yy, yz;
cin>>yx>>yy>>yz;
P.tellmeyourpoint(yx, yy, yz);
P.showpoint();
return 0;
}