#include #include #include //for strcmp #include //for wcscmp #include "date.h" using namespace std; int min(int a, int b); //function declaration double min(double a, double b); date min(date a, date b); const char *min(const char *a, const char *b); const wchar_t *min(const wchar_t *a, const wchar_t *b); int main() { date today; date tomorrow = today + 1; //= operator+(today, 1); cout << ::min(10, 20) << "\n" //calls line 29 << ::min(3.14, 2.71) << "\n" //calls line 34 << ::min(today, tomorrow) << "\n" //calls line 39 << ::min("hello", "goodbye") << endl; //calls line 44 wcout << ::min(L"hello", L"goodbye") << L"\n"; //calls line 50 return EXIT_SUCCESS; } int min(int a, int b) //function definition { return b < a ? b : a; //why not return a < b ? a : b; } double min(double a, double b) { return b < a ? b : a; } date min(date a, date b) //should be passed and returned by reference { return b < a ? b : a; //return operator<(b, a) ? b : a; } const char *min(const char *a, const char *b) { //return b < a ? b : a; would be wrong for this data type return strcmp(b, a) < 0 ? b : a; } const wchar_t *min(const wchar_t *a, const wchar_t *b) { return wcscmp(b, a) < 0 ? b : a; //wide character string compare }