fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class C {
  6. public:
  7. C& first() {
  8. cout << "first\n" ;
  9. return *this;
  10. };
  11. C& second() {
  12. cout << "second\n";
  13. return *this;
  14. };
  15. C& third() {
  16. cout << "third\n" ;
  17. return *this;
  18. };
  19. };
  20.  
  21.  
  22. int main(int argc, char* argv[]) {
  23. C c;
  24. c.first().second().third();
  25. }
  26.  
Success #stdin #stdout 0.01s 5520KB
stdin
Standard input is empty
stdout
first
second
third