chain function calls c 2b 2b

Solutions on MaxInterview for chain function calls c 2b 2b by the best coders in the world

showing results for - "chain function calls c 2b 2b"
Lennart
17 Apr 2020
1class foo
2{
3  private:
4    int x;
5    int y;
6  public:
7    foo& setx(int x_)
8    {   x = x_;
9        return *this; }
10    foo& sety(int y_)
11    {   y = y_;
12        return *this; }
13    foo& print()
14    {std::cout << x << ' ' << y;
15     return *this;}
16};
17
18int main()
19{
20    foo bar;
21    bar.setx(1).sety(2).print();
22}