View Code
#include<iostream>
using namespace std;
class point{
public :
int x,y;
point();
point(int x,int y);
~point();
};
void main()
{
point p1;
point p2(800,600);
cout<<"p1: "<<p1.x<<" "<<p1.y<<endl;
cout<<"p2: "<<p2.x<<" "<<p2.y<<endl;
}
point:: point()
{
cout<<"调用了默认构造函数"<<endl;
x=0;
y=0;
}
point::point(int x,int y)
{
cout<<"调用了非默认构造函数"<<endl;
this->x=x;
this->y=y;
}
point::~point()
{
cout<<"调用了析构函数"<<endl;
}

相关文章:

  • 2021-11-18
  • 2021-08-13
  • 2021-07-07
  • 2021-06-25
  • 2021-09-14
  • 2021-05-25
  • 2021-06-24
  • 2021-04-14
猜你喜欢
  • 2021-05-07
  • 2021-09-06
  • 2022-01-08
  • 2022-02-08
  • 2022-12-23
相关资源
相似解决方案