1 2 struct bar; 3 struct foo 4 { 5 operator bar*(); 6 auto operator<=>(const foo& rhs) const = default; 7 }; 8 9 class Foo { 10 Foo operator +(const Foo& rhs) const; 11 12 const Foo& operator==(Foo& me); 13 14 bool operator >(const Foo& rhs) const; 15 16 InStream& operator <<(InStream& in); 17 } 18 operator ==(Foo & me)19const Foo& Foo::operator==(Foo& me) 20 { 21 } 22 operator +(const Foo & rhs) const23Foo Foo::operator+(const Foo& rhs) const 24 { 25 } 26 operator >(const Foo & rhs) const27bool Foo::operator>(const Foo& rhs) const 28 { 29 } 30 31 class Example 32 { 33 char m_array[256]; 34 35 Example& operator =(const Example& rhs); 36 Example& operator +=(const Example& rhs); 37 const Example operator+(const Example& other) const; 38 bool operator ==(const Example& other) const; 39 bool operator !=(const Example& other) const; 40 Example operator +(const Example& x, const Example& y); 41 Example operator *(const Example& x, const Example& y); 42 43 double& operator ()(int row, int col); 44 double operator ()(int row, int col) const; 45 void operator ++(); 46 int& operator *(); 47 Example& operator ++(); // prefix ++ 48 Example operator ++(int); // postfix ++ 49 50 bool operator <(const Example& lhs, const Example& rhs) const; 51 operator ()(int index)52 int operator()(int index) 53 { 54 i = ~~3; 55 return index + 1; 56 } 57 operator [](unsigned i)58 char& operator[](unsigned i) 59 { 60 return m_array[i & 0xff]; 61 } 62 } operator ==(const Example & other) const63bool Example::operator==(const Example& other) const 64 { 65 /*TODO: compare something? */ 66 return false; 67 } operator !=(const Example & other) const68bool Example::operator!=(const Example& other) const 69 { 70 return !operator==(other); 71 } 72 73 a()74void a() { 75 Op op = &X::operator==; 76 if (!A) 77 if (op != &X::operator==) 78 A(1) = a; 79 if (!A) { 80 if (op != &X::operator==) 81 A(1) = a; 82 } 83 } 84 85 void *operator new(std::size_t) throw(std::bad_alloc); 86 void *operator new[](std::size_t) throw(std::bad_alloc); 87 void operator delete(void *) throw(); 88 void operator delete[](void *) throw(); 89