#include<iostream>
using std::cout;
using std::endl;
class C
{
public:
C &setX(int x)
{
this->x=x;
return *this;
}
C &setY(int y)
{
this->y=y;
return *this;
}
int getX() const
{
return this->x;
}
int getY() const
{
return this->y;
}
private:
int x;
int y;
};
int main()
{
C c;
c.setX(3).setY(45);
cout<<c.getX()<<"\t"<<c.getY()<<endl;
return 0;
}
//带this指针的串联式成员函数调用
重学C++ 带this指针的串联式成员函数调用
最新推荐文章于 2022-06-09 10:49:12 发布