Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,499 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,378 people online right now. Registration is fast and FREE... Join Now!




Dont understand this error

 
Reply to this topicStart new topic

Dont understand this error

dt52fast
23 Mar, 2007 - 07:10 PM
Post #1

New D.I.C Head
*

Joined: 21 Mar, 2007
Posts: 11


My Contributions
I am working this program and it is now giving me a error that I do not know how to resolve. The exact error says error C2064 term does not evaluate to a function taking 3 arguments. I did move the initialization of the dayNumber function inside of the getDate function. That is when this error started. I appreciate any help I can get. Any other suggestions on modifing this code will also be appreciated.

Thanks Kerry

Here is the code (sorry it is so long)
CODE

//Kerry Cain
//Sequence Assn. Part 3
//displays the character entered as well as its ASCII value

#include <iostream>
#include <iomanip>
using namespace std;

void getDate ();
int validDate (int&, int&, int&);
int dayNumber (int&, int&, int&);
bool isLeapyear (int year);




int main()
{
    int month;
    int day;
    int year;

    cout << "\nThis program will read in a date and return the date \n";
    cout << "\nIt will also display the number the day is of that year "<< endl;
    cout << "\nThe year must be between 1 and 3000 " << endl;
    cout << "\n";

    getDate ();



    return 0;
}

void getDate ()
{
    char Y;
    char cont = Y;

    while (cont != 'N')
    {
        int month;
        int day;
        int year;
        char b;
        int daycount;
        int dayNumber;



            cout << "\nPlease enter a date in the form month/day/year: ";
            cin >> month >> b >> day >> b >> year;
            cout <<endl;
            validDate (month, day, year);
            dayNumber (month, day, year);
            cout << setw (2) << setfill ('0') << day << "-";
            switch (month)
            {
                case 1:
                     cout <<"January";
                     break;
                case 2:
                     cout <<"February";
                     break;
                case 3:
                     cout <<"March";
                     break;
                case 4:
                     cout <<"April";
                     break;
                case 5:
                     cout <<"May";
                     break;
                case 6:
                     cout <<"June";
                     break;
                case 7:
                     cout <<"July";
                     break;
                case 8:
                     cout <<"August";
                     break;
                case 9:
                     cout <<"September";
                     break;
                case 10:
                     cout <<"October";
                     break;
                case 11:
                     cout <<"November";
                     break;
                case 12:
                      cout <<"December";
                      break;
            }
            cout << "-";
            cout << setw (4) << setfill ('0') << year;
            cout << " is day number "<<day<< " in year "<<year<<endl;
            cout <<endl;
            cout << "If you wish to exit program please enter N to keep going enter Y: ";
            cin >>cont;
            cout <<endl;

    }

    return;
}

bool isLeapyear (int year)
{
    if (year % 400 == 0 || ( year % 4 == 0 && year % 100 != 0 ) )
        return true;
    else
        return false;
}

int validDate (int& month, int& day, int& year)
{
    int daysinmonth = 0;

    if (month >= 1 && month <=12)
    {

    }
    else
    {
        cout <<"Error the month is not in the valid range!!"<<endl;
    }
    if (year >=1 && year <=3000)
    {
    ;
    }
    else
    {
        cout <<"Error you have input an invalid year!! "<<endl;
    }
    if (month == 9|| month == 4 || month == 6 || month == 11)
    {
        daysinmonth = 30;
    }
    else if (month == 2)
    {
        if (isLeapyear(year))
            daysinmonth = 29;
        else
            daysinmonth = 28;
    }
    else
    {
        daysinmonth = 31;
    }
    if (day < daysinmonth)
    ;
    else
    {
    cout <<"Error you have input an invalid day number!! "<<endl;
    }

        return (daysinmonth);
}

int dayNumber (int& month, int& day, int& year)
{

    int daycount = day;

        if (month > 1)
            daycount = daycount + 31;
        if (month > 2)
        {
            if (isLeapyear (year))
                daycount = daycount + 29;
            else
                daycount = daycount + 28;
        }
        if (month > 3)
            daycount = daycount + 31;
        if (month > 4)
            daycount = daycount + 30;
        if (month > 5)
            daycount = daycount + 31;
        if (month > 6)
            daycount = daycount + 30;
        if (month > 7)
            daycount = daycount + 31;
        if (month > 8)
            daycount = daycount + 31;
        if (month > 9)
            daycount = daycount + 30;
        if (month > 10)
            daycount = daycount + 31;
        if (month > 11)
            daycount = daycount + 30;

    cout <<"daycount is now "<<daycount<<endl;

    return (daycount);
}

User is offlineProfile CardPM
+Quote Post

NickDMax
RE: Dont Understand This Error
23 Mar, 2007 - 08:00 PM
Post #2

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,867



Thanked: 53 times
Dream Kudos: 550
My Contributions
well the problem is that you declare dayNumber in two ways... once as a function and then inside of getDate() you declare it as int dayNumber; which confuses the compiler. Since the number was in the immediate scope the compiler *assumed* that is what you meant. I got it to compile by commenting out the variable version.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/7/09 06:24PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month