6.3w+
社区成员
#include <iostream>
class point
{private:
int x,y;
public:
point(int xx=0,int yy=0)
{x=xx;
y=yy;
cout < <"构造函数被调用" < <endl;
}
point(point &p);
~point(){cout < <"析构函数被调用" < <endl;}
int get_x(){return x;}
int get_y(){return y;}
};
point::point(point &p)
{x=p.x;
y=p.y;
cout < <"拷贝函数被调用" < <endl;
}
void main()
{point a(12,22) //你就一个问题,就是这个地方缺了个分号
point b(a);
cout < <b.get_x() < <"" < <b.get_y() < <endl;
}
#include <iostream>
class point
{private:
int x,y;
public:
point(int xx=0,int yy=0)
{x=xx;
y=yy;
cout < <"构造函数被调用" < <endl;
}
point(point &p);
~point(){cout < <"析构函数被调用" < <endl;}
int get_x(){return x;}
int get_y(){return y;}
};
point::point(point &p)
{x=p.x;
y=p.y;
cout < <"拷贝函数被调用" < <endl;
}
void main()
{point a(12,22) //你就一个问题,就是这个地方缺了个分号
point b(a);
cout < <b.get_x() < <"" < <b.get_y() < <endl;
}
#include <iostream>
class point
{private:
int x,y;
public:
point(int xx=0,int yy=0)
{x=xx;
y=yy;
cout < <"构造函数被调用" < <endl;
}
point(point &p);
~point(){cout < <"析构函数被调用" < <endl;}
int get_x(){return x;}
int get_y(){return y;}
};
point::point(point &p)
{x=p.x;
y=p.y;
cout < <"拷贝函数被调用" < <endl;
}
void main()
{point a(12,22) //你就一个问题,就是这个地方缺了个分号
point b(a);
cout < <b.get_x() < <"" < <b.get_y() < <endl;
}
#include <iostream>
using namespace std;
class point
{
private:
int x,y;
public:
point(int xx=0,int yy=0)
{x=xx;
y=yy;
cout <<"构造函数被调用" <<endl;
}
point(point &p);
~point(){cout <<"析构函数被调用" <<endl;}
int get_x(){return x;}
int get_y(){return y;}
};
point::point(point &p)
{x=p.x;
y=p.y;
cout <<"拷贝函数被调用" <<endl;
}
void main()
{
point a(12,22);
point b(a);
cout <<b.get_x() <<"" <<b.get_y() <<endl;
}
#include <iostream>
using namespace std;
class point
{
private:
int x,y;
public:
point(int xx=0,int yy=0)
{
x = xx;
y = yy;
cout << "构造函数被调用" << endl;
}
point(point &p);
~point()
{
cout << "析构函数被调用" << endl;
}
int get_x(){return x;}
int get_y(){return y;}
};
point::point(point &p)
{
x = p.x;
y = p.y;
cout << "拷贝函数被调用" << endl;
}
int main()
{
point a(12, 22);
point b(a);
cout << b.get_x() << " " << b.get_y() << endl;
return 0;
}