c++入门

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;
}
posted @ 2011-12-07 10:38  Because Of You  Views(243)  Comments(0Edit  收藏  举报