C++ Getting wrong answer no matter what
<p>Alright, this is my first year as a C++ programmer. and my next C++ homework is due on the 5th. We have to write three functions. One function, "getJulianDate" takes 3 data type "int" variables, passes those to a "isValidDate" function, which utilizes a "isLeapYear" function to make sure everything is flawless.</p>

<p>My problem is, I'm kind of blanking out on getting these functions down. I have isLeapYear done, and the bulk of getJulianDate done, but the middle function "isValidDate" is just making me angry now.</p>

<p>EDIT 1: Solved it!</p>

<p>EDIT 2: Solved it!</p>

<p>EDIT 3: Okay, so it compiles perfect now. But every time I enter my date, it always returns the -1, even if it is a valid date</p>

<p>"/out:Testfunction.exe
Testfunction.obj
Testfunction.obj : error LNK2019: unresolved external symbol "bool __cdecl isLeapYear(int)" (?isLeapYear@@YA_NH@Z) referenced in function "bool __cdecl isValidDate(int,int,int)" (?isValidDate@@YA_NHHH
@Z)
Testfunction.exe : fatal error LNK1120: 1 unresolved externals"</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

long getJulianDayNumber (int d, int m, int y);
bool isValidDate (int d, int m, int y);
bool isLeapYear (int y);

int d, m, y;

void main()
{
    // get day/month year from user
    cout &lt;&lt; "Enter a date:" &lt;&lt; endl;
    cin &gt;&gt; d, m, y;

    // get julian date function
    cout &lt;&lt; getJulianDayNumber(d, m, y);
}

long getJulianDayNumber (int d, int m, int y)
{
//1. Send (day, month, year) to isValid Date
 if(isValidDate(d, m, y)){
//5. MORE SHIT MATH, post results to user
return (1461 * (y + 4800 + (m - 14)/12))/4 +(367 * (m - 2 - 12 * ((m - 14)/12)))/12 - (3 * ((y + 4900 + (m - 14)/12)/100))/4 + d - 32075;
}
else{
return -1;
}
}


bool isValidDate(int d, int m, int y)
    { 
// CHECK DATES BETWEEN JAN 1 1601 AND DEC 31 2099
    //2. Call isLeapYear to check for leap yea
    if(m == 0 || d == 0 || y == 0){
        return 0;
    }
    if(m &gt; 12){
        // if we have more than 12 months...
        return 0;
    }
    if(!(y &gt;= 1601 &amp;&amp; y &lt;= 2099)){
        // if the year is NOT greater than or equal to 1601
        // and less than or equal to 2099
        return 0;
    }


    if(m == 2){
        if(isLeapYear(y)){
            if(!(d &gt; 29)){
                return 0;
            }
            // 29 days in February this year
        }else{
            if(!(d &gt; 28)){
                return 0;
            }
            // 28 days in February this year
        }
    }else{
        if(m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12){
            if(!(d &gt; 31)){
                return 0;
            }
            // 31 days
        }else{
            if(!(d &gt; 30)){
                return 0;
            }
            // 30 days
        }
    }
    //4. Do some shit math and find out if it is a valid date, if yes send to     getJulian
    //    If no, return a -1
    return 1;
}

bool isLeapyear (int y)
{
// 3. Return 1 or 0 // TRUE or FALSE
    return (y % 400 == 0 || y % 4 == 0 &amp;&amp; y % 100 != 0);
}
</code></pre>

<hr>

<p>Any help? It's apparently something wrong with my first cout statement.</p>
