Skip to content

Commit 23a35d7

Browse files
committed
Update 4.md
1 parent 8df4ad8 commit 23a35d7

File tree

1 file changed

+4
-4
lines changed
  • docs/documentation/tips_and_tricks

1 file changed

+4
-4
lines changed

docs/documentation/tips_and_tricks/4.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ Yes, of course you can store your own type in [xtd::collections::array_list](htt
4040
#include <xtd/xtd>
4141

4242
struct foo {
43-
int value;
44-
4543
bool operator ==(const foo& f) const noexcept {return value == f.value;}
4644
bool operator <(const foo& f) const noexcept {return value < f.value;}
4745
bool operator >(const foo& f) const noexcept {return value > f.value;}
46+
47+
int value;
4848
};
4949

5050
struct bar : public icomparable<bar>, public iequatable<bar> {
@@ -55,7 +55,6 @@ struct bar : public icomparable<bar>, public iequatable<bar> {
5555
bool equals(const bar& obj) const noexcept override {return value == obj.value;}
5656

5757
int value;
58-
5958
};
6059

6160
auto main() -> int {
@@ -83,7 +82,8 @@ auto main() -> int {
8382
```
8483

8584
* The only constraint is declaring at least the following three operators: `==`, `<` and `>` as in the example with the `foo` structure.
86-
* Or to inherit the interfaces [xtd::icomparable](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1icomparable.html) and [xtd::iequatable](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1iequatable.html) as in the example with the structure `bar`.
85+
* Or to inherit the interfaces [xtd::icomparable](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1icomparable.html) and [xtd::iequatable](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1iequatable.html) as in the example with the structure `bar`.
86+
Indeed, the interface [xtd::icomparable](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1icomparable.html) automatically creates comparison operators and the interface [xtd::iquatable](https://gammasoft71.github.io/xtd/reference_guides/latest/classxtd_1_1iquatable.html) also automatically creates equality and inequality operators.
8787

8888
## Conclusion
8989

0 commit comments

Comments
 (0)