max value

Discussion in 'Programmer's Corner' started by coolroose, Feb 27, 2012.

  1. coolroose

    Thread Starter New Member

    Aug 31, 2010
    when i compiled/run this program i got the following error:

    fatal error C1083: Cannot open include file: 'maximum.h': No such file or directory

    can someone help figure out the error please.

    // maxi.cpp
    //write a template function, MAX, to find the maximum number of 3 integers, 3 doubles//
    #include <iostream>
    #include "maximum.h"// include definition of function template max
    using namespace std;
    int main()
    int int1, int2, int3//max integer values

    cout <<"Please input three integer values: ";
    cin >> int1 >> int2 >> int3;

    cout << "The maximum integer value is: "//int max value
    << Maximum( int1, int2, int3 );

    double double1, double2, double3;// max with double values

    cout << "\n\n Please input three double values: ";//
    cin >> double1>> double2 >> double3;

    cout << "The maximum double value is: "// find the max double value
    << Maximum( double1, double2, double3 );

    char char2, char2, char3;// get the cahr values

    cout << "\n Please input three characters: ";
    cin >> char1 >> char2 >> char3;

    //find the max character value
    cout << "The Maximum character value is: "
    << maximum(char1, char2, char3 ) << endl;

    return 0;
    }//end main


    //function template maximum
    #ifndef max_H
    #define max_H
    #include <iostream>

    template < class T >
    T maximum( T value1, T value2, T value3 )
    T maximumValue = value1;//check if value1 is max

    if ( value2 > maximumValue )//check is value2 is max
    maximumValue = value2;

    if ( value3 > maximumValue )//check if value3 is max
    maximumValue = value3;

    return maximumValue;
    }//end template
    Last edited: Feb 28, 2012
  2. cheezewizz

    Active Member

    Apr 16, 2009
    Well if your header file is called maxi.h (as indicated by your code) then you need to include "maxi.h" "not maximum.h"... If it is in fact called maximum.h then you might need to tell your compiler where to find it.