tailieunhanh - HandBooks Professional Java-C-Scrip-SQL part 56

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 56', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | boost addable simple_string boost addable simple_string const char The Difference Between Equality and Equivalence When defining relational operators for classes it s important to make the distinction between equality and equivalence. An equivalence relation is required in order to use the associative containers and it defines a strict weak ordering through the concept This relation makes the least assumptions and poses as few requirements as possible for types that are to be used with the Standard Library containers. However the difference between equality and equivalence can sometimes be confusing and it is important to understand the difference. When a class supports the concept LessThanComparable it typically also supports the notion of equivalence. If two elements are compared and neither is less than the other we can consider them to be equivalent. However equivalence doesn t necessarily mean equal. For example it may be reasonable to omit certain characteristics from a less than relation but consider them for To illustrate this let s look at a class animal which supports both an equivalence relation and an equality relation. 11 Capitalized concepts like LessThanComparable come straight from the C Standard. All of the concepts in use lowercase names. 12 Which implies a strict weak ordering but not a total ordering. class animal boost less_than_comparable animal boost equality_comparable animal std string name_ int age_ public animal const std string name int age name_ name age_ age void print const std cout name_ with the age age_ n friend bool operator const animal lhs const animal rhs return friend bool operator const animal lhs const animal rhs return Notice the difference between the implementation of operator and that of operator . Only the animal s name is part of the less than relation whereas comparison of both the name and the age comprise .

TÀI LIỆU LIÊN QUAN
10    158    1
6    184    1
7    162    1
5    157    1
6    160    1
6    152    1
6    150    1
6    206    1
7    154    1