January 2019
Intermediate to advanced
512 pages
14h 5m
English
The problem we considered in the previous section, calling a sort() member function if one exists, naturally led us to ask the question Does a sort() member function exist? We came up with two ways to ask this question—first, we can ask Does the class have a member function named sort, and what is the type of a pointer to it? This question fails when the answer is yes, it has two, and the type of the pointer depends on which one you mean. The second way to ask was Does the class have a void sort() member function? This question fails when the answer is No, but it has one that you can call anyway. Perhaps the question we should have asked all along was, If I write x.sort(), will it compile?
To avoid falling into this ...