fork download
  1. #include <iostream>
  2.  
  3. class Animal
  4. {
  5. public:
  6. int x;
  7. int y;
  8. int z;
  9. Animal & setx(int v) { x = v; return *this;}
  10. Animal & sety(int v) { y = v; return *this;}
  11. Animal & setz(int v) { z = v; return *this;}
  12. };
  13.  
  14. int main() {
  15. // your code goes here
  16.  
  17. Animal anml;
  18. anml.setx(5).sety(6).setz(7);
  19. std::cout << anml.x << ", " << anml.y << ", " << anml.z << std::endl;
  20. return 0;
  21. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
5, 6, 7