minTest.cpp

URL: http://147.64.242.52/~bennett/class/cmsc2040/fall2026/notes/templates/code/minTest.cpp
 
#include <iostream>
#include <string>

#include "MinT.h"

using namespace std;

int main() {
    // test for ints
    int a{10}, b{5};

    cout << "ints " << endl;
    cout << "the min of " << a << " and " << b << " is " << Min(a,b) << endl;
    cout << "the min of " << b << " and " << a << " is " << Min(b,a) << endl;
    cout << "the min of " << a << " and " << 12 << " is " << Min(a,12) << endl;
    cout << "the min of " << 12 << " and " << a << " is " << Min(12,a) << endl;

    cout << endl << endl;

    cout << "floats " << endl;
    // let's try some floats;
    float x{1.122f}, y{5.31f};
    cout << "the min of " << x << " and " << y << " is " << Min(x,y) << endl;
    cout << "the min of " << y << " and " << x << " is " << Min(y,x) << endl;

    cout << endl << endl;


    cout << "Mix them up " << endl;
    cout << "the min of " << b << " and " << y << " is "
         << Min<float>(b,y) << endl;
    cout << "the min of " << y << " and " << b << " is "
         << Min<int>(y,b) << endl;

    cout << endl << endl;

    cout << "shorts and longs " << endl;
    short c{3},d{2};
    cout << "the min of " << c << " and " << d << " is " << Min(c,d) << endl;
    long e{7},f{99};
    cout << "the min of " << e << " and " << f << " is " << Min(e,f) << endl;

    cout << endl << endl;

    cout << "Strings" << endl;
    string word1{"hello"}, word2{"world"};
    cout << "the min of " << word1 << " and " << word2 << " is " << Min(word1,word2) << endl;

    return 0;
}