1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

#include <iostream>
#include <limits>
#include "MaxValue.h"
// simple macro for demo purposes
#define COUNTOF(a) (sizeof(a) / sizeof(a[0]))
using namespace std;
int main(){
const int a[] = { 66, 9, 1, 343, 2, 44};
const int b[] = { 67, 3, 111, 4};
const int c[] = {443, 5, 52, 6};
const int d[] = {0};
MaxValue max_of_a(a, COUNTOF(a));
MaxValue max_of_b(b, COUNTOF(b));
MaxValue max_of_c(c, COUNTOF(c));
MaxValue max_of_d(d, 0);
MaxValue max_zero;
cout << "max_of_a = " << max_of_a << endl;
cout << "max_of_b = " << max_of_b << endl;
cout << "max_of_c = " << max_of_c << endl;
cout << "max_of_d = " << max_of_d << endl;
cout << "max_zero = " << max_zero << endl;
cout << endl;
cout << "2 x max_of_a = " << 2 * MaxValue(a, COUNTOF(a)) << endl;
cout << endl;
cout << "sum of max values (a, b, c) = "
<< max_of_a + max_of_b + max_of_c << endl;
int mean = (max_of_a + max_of_b + max_of_c) / 3;
cout << "mean of max values (a, b, c) = " << mean << endl;
cout << endl;
MaxValue min_of_max = numeric_limits<int>::max();
if (max_of_a < min_of_max)
min_of_max = max_of_a;
if (max_of_b < min_of_max)
min_of_max = max_of_b;
if (max_of_c < min_of_max)
min_of_max = max_of_c;
cout << "min of max values (a, b, c) = " << min_of_max << endl;
cout << endl;
return 0;
}
