Thread: error C2664

  1. #1
    Registered User
    Join Date
    Feb 2006

    Question error C2664

    I have this code that I am trying to compile and I keep getting an error C2664 message. I am not sure what to do with the code that it is pointing to. (This is just part of the program code but I get this same error in another part of the code)
    #include <iostream>
    using std::cout;
    using std::endl;
    #include <ctime>
    #include <cstdlib>
    enum Months { JAN = 1, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC };
    void generateDate( int &, int &, int );
    void printDate( Months, int, int );
    int validDate( int, int );
    int main()
        int month = 1;
        int day = 1;
        int year = 1900;
    	int getYear;
    	int getMonth;
    	int getDay;
    	int Month;
    	int myMonth;
        srand( time( 0 ) );
        printDate( month, day, year );
        year = getYear ( year );
        month = getMonth( month );
        day = getDay( day );
        if (validDate (month, day, year) == true )
            printDate ( month, day, year );
        return 0;
    }   // end main
    This is the whole error message:
    error C2664: 'printDate' : cannot convert parameter 1 from 'int' to 'enum Months'
    Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)

    Any help will be appreciated.

  2. #2
    Mad OnionKnight's Avatar
    Join Date
    Jan 2005
    Umeň, Sweden
    int month = 1;
    Months month = JAN;

Popular pages Recent additions subscribe to a feed