[求助]关于this指针
#include<iostream.h>
class exam{
int x,y;
public:
exam( int a,int b ){x=a;y=b;}
void print( );
void swap( exam &);
};
void exam::print( )
{ cout<<"x="<<this->x<<endl;
cout<<"y="<<this->y<<endl;}
void exam::swap( exam &xy)
{ exam t;
t=*this; *this=xy; xy=t; }
void main( )
{
exam a(3,6),b(1,5);
a.print( );b.print( );
a.swap(b);
a.print( );b.print( );
b.swap(a);
a.print( );b.print( );
}
这段程序中void exam::swap( exam &xy) 中的&xy是什么意思呢?
当程序执行到a.swap(b);时候*this为什么会指向对象a呢?