Answers for "chain function calls c++"

C++
0

chain function calls c++

class foo
{
  private:
    int x;
    int y;
  public:
    foo& setx(int x_)
    {   x = x_;
        return *this; }
    foo& sety(int y_)
    {   y = y_;
        return *this; }
    foo& print()
    {std::cout << x << ' ' << y;
     return *this;}
};

int main()
{
    foo bar;
    bar.setx(1).sety(2).print();
}
Posted by: Guest on June-21-2021

Code answers related to "chain function calls c++"

Browse Popular Code Answers by Language