64,641
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
long x = 1, y = x + 5;
class A{
public:
long x;
static long &y;
operator long (){return x+y;}
A & operator ++(){x++;y++;return *this;}
A(long x=::x+3,long y=::y+5){A::x=x;A::y=y;}
};
long &A::y=::y;
int main(void)
{
A a,b(a),c(3,7);
long i,&m=i,A::*p=&A::x;
cout<<(i=A::y)<<endl;
cout<<(i=b.x)<<endl;
cout<<(i=b.*p)<<endl;
cout<<(i=::y+A(4))<<endl;
cout<<(i=b+a)<<endl;
cout<<(i=++ ++a)<<endl;
system("pause");
return 1;
}