|
|
1.1 ! root 1: #include "String.h" ! 2: ! 3: struct Foo { ! 4: Foo() {} ! 5: Foo(Foo& x) { *this = x; } ! 6: ~Foo() {} ! 7: Foo& operator=(Foo& x) { s[0] = x.s[0]; s[1] = x.s[1]; return *this; } ! 8: String s[2]; ! 9: }; ! 10: ! 11: Foo ! 12: zot(Foo x) ! 13: { ! 14: x.s[0] += "zot"; ! 15: x.s[1] += "zotzot"; ! 16: return x; ! 17: } ! 18: ! 19: ostream& ! 20: operator<<(ostream& o, Foo& x) ! 21: { ! 22: return o << "Foo::s[*]: " << x.s[0] << " " << x.s[1]; ! 23: } ! 24: ! 25: main() ! 26: { ! 27: Foo x; ! 28: x.s[0] = "hello"; ! 29: x.s[1] = "hello"; ! 30: cout << zot(x) << "\n"; ! 31: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.