fork download
  1. class Foo
  2. {
  3. private:
  4. int iX;
  5. public:
  6. Foo() { iX = 5; };
  7.  
  8. int getData()
  9. {
  10. return iX;
  11. }
  12.  
  13. Foo& operator=(const Foo &RHS);
  14. };
  15.  
  16. Foo& Foo::operator=(const Foo &RHS)
  17. {
  18. if(this != &RHS)
  19. { // the if this test prevents an object from copying to itself (ie. RHS = RHS;)
  20. this->iX = RHS.iX; // this is suitable for this class, but can be more complex when
  21. // copying an object in a different much larger class
  22. }
  23.  
  24. return (*this); // returning an object allows chaining, like a = b = c; statements
  25. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/bin/../lib/gcc/i586-linux-gnu/4.9/../../../i386-linux-gnu/crt1.o: In function `_start':
/build/glibc-5CYv_T/glibc-2.19/csu/../sysdeps/i386/start.S:111: undefined reference to `main'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
stdout
Standard output is empty