TAILIEUCHUNG - HandBooks Professional Java-C-Scrip-SQL part 54

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 54', 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ả | Usage To start using the Operators library implement the applicable operator s for your class include boost and derive from one or more of the Operator base classes they have the same names as the concepts they help implement which all reside in namespace boost. Note that the inheritance doesn t have to be public private inheritance works just as well. In this usage section we look at several examples of using the different concepts and also take a good look at how arithmetic and relational operators work both in C and conceptually. For the first example of usage we ll define a class some_class with an operator . We decide that the equivalence relation implied by operator should be made available through operator . This can be accomplished by inheriting from boost equivalent. include iostream include boost class some_class boost equivalent some_class int value_ public some_class int value value_ value bool less_than const some_class other const return value_ bool operator const some_class lhs const some_class rhs return rhs int main some_class s1 12 some_class s2 11 if s1 s2 std cout s1 s2 n else std cout s1 s2 n The operator is implemented in terms of the member function less_than. The requirement for the equivalent base class is that operator be present for the class in question. When deriving from equivalent we pass the derived classthat is some_classas a template parameter. In main the operator that is graciously implemented for us by the Operators library is used. Next we ll take a look at operator again and see what other relations can be expressed in terms of less than. Supporting Comparison Operators A relational operator that we commonly implement is less thanthat is operator . We do so to support storage in associative containers and sorting. However it is exceedingly common to supply only that operator which can be confusing to users of the class. For example most people know that negating the result

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.