fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Foo
  5. {
  6. public:
  7. int x;
  8.  
  9. private:
  10.  
  11. Foo(const Foo& foo) : x(foo.x) { }
  12. Foo& operator=(const Foo& foo) { x = foo.x; }
  13. public:
  14. Foo(int x) : x(x) { }
  15.  
  16. static void copy(const Foo& from, Foo& to) { to = from; }
  17. };
  18.  
  19. int main() {
  20. Foo foo(5);
  21. Foo foo2(10);
  22. Foo::copy(foo, foo2);
  23. std::cout << foo2.x << std::endl;
  24. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
5