"Function Does Not Take 0 Arguments" Error

Help! I have been trying to figure this error out for an hour and can't get it!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// DayOfTheWeek.cpp : main project file.

#include <iostream>
#include <string>

using namespace std;

class DayOfTheWeek 
{
public:
	void setDay(string);
		// setDay(string) takes a string parameter 
		// and stores the value in the day attribute.
	void printDay() const;
		// printDay() prints the value of the day attribute
		// on console output (cout).
	string getDay() const;
		// returns the value of the day attribute.
	string plusOneDay(int, int &, int &, string);
	string minusOneDay(int, int &, int &, string);
	int addDays();
private:
	string day; // This is where the value of the day attribute is stored.
	int convertToInt(string);
	string ConvertToString(int);
};

string DayOfTheWeek::getDay() const { 
	return day; 
}

void DayOfTheWeek::setDay(string newDay) { 
	day = newDay; 
}

void DayOfTheWeek::printDay() const { 
	cout << day; 
}

//the convertToInt function converts a string argument into an int
int DayOfTheWeek::convertToInt(string sValue){
    int iNum=0;
    if(sValue=="Sunday"){iNum=0;}
    else if(sValue=="Monday"){iNum=1;}
    else if(sValue=="Tuesday"){iNum=2;}
    else if(sValue=="Wednesday"){iNum=3;}
    else if(sValue=="Thursday"){iNum=4;}
    else if(sValue=="Friday"){iNum=5;}
    else if(sValue=="Saturday"){iNum=6;}
    else{cout<<"The string entered is not a day of the week! Setting day to Monday."<<endl; iNum=1;}
    return iNum;
}

//the convertToString function converts an int value into a string
string DayOfTheWeek::ConvertToString(int intValue){
    string dayVariable="";
    switch (intValue){
    case '0': dayVariable="Sunday"; break;
    case '1': dayVariable="Monday"; break;
    case '2': dayVariable="Tuesday"; break;
    case '3': dayVariable="Wednesday"; break;
    case '4': dayVariable="Thursday"; break;
    case '5': dayVariable="Friday"; break;
    case '6': dayVariable="Saturday"; break;
    }
    return dayVariable;
}

string DayOfTheWeek::plusOneDay(int addDay, int &iNum, int &dayVariable, string addDayString){
	addDay = iNum + 1;
	ConvertToString(addDay);
	addDayString = dayVariable;
	return addDayString;
}

string DayOfTheWeek::minusOneDay(int minusDay, int &iNum, int &dayVariable, string minusDayString){
	minusDay = iNum - 1;
	ConvertToString(minusDay);
	minusDayString = dayVariable;
	return minusDayString;
}

int main()
{
    
	DayOfTheWeek monday;
	DayOfTheWeek tuesday;

	// Set the values of the objects
	monday.setDay("Mon");
	tuesday.setDay("Tues");

	// Get the value of the monday object and print it out
	string currentDay = monday.getDay();
	cout << "The value of the monday object is " << currentDay << "." << endl;


	// Print out the value of the next day
	string nextDay = monday.plusOneDay();
	cout << "The day after Monday is " << nextDay << "." << endl;

	// Print out the value of the previous day
	string previousDay = monday.minusOneDay();
	cout << "The day before Monday is " << previousDay << "." << endl;

	// We're finished
	return 0;
}


1
2
3
4
5
6
7
8
9
10
11
1
1>Build started 7/17/2011 1:42:05 PM.
1>_PrepareForClean:
1>  Deleting file "Debug\Week2Lab_NicholasMarlatt.lastbuildstate".
1>InitializeBuildStatus:
1>  Touching "Debug\Week2Lab_NicholasMarlatt.unsuccessfulbuild".
1>ClCompile:
1>  DaysOfWeek.cpp
1>c:\users\nick\documents\visual studio 2010\projects\week2lab_nicholasmarlatt\week2lab_nicholasmarlatt\daysofweek.cpp(99): error C2660: 'DayOfTheWeek::plusOneDay' : function does not take 0 arguments
1>c:\users\nick\documents\visual studio 2010\projects\week2lab_nicholasmarlatt\week2lab_nicholasmarlatt\daysofweek.cpp(103): error C2660: 'DayOfTheWeek::minusOneDay' : function does not take 0 arguments
1>
1>Build FAILED.
You have declared those functions to take 4 parameters:

1
2
3
// lines 19-20
string plusOneDay(int, int &, int &, string);
string minusOneDay(int, int &, int &, string);


But here you are calling them with no parameters:

1
2
string nextDay = monday.plusOneDay(); // line 99
string previousDay = monday.minusOneDay(); // line 103 


It wants you to pass 4 parameters on those lines.

ahh... ok. that makes sense, now I am running into the issue that I am declaring these parameters when the function is being performed:

1
2
3
4
5
6
7
8
9
10
11
12
13
string DayOfTheWeek::plusOneDay(int addDay, int &iNum, int &dayVariable, string addDayString){
	addDay = iNum + 1;
	ConvertToString(addDay);
	addDayString = dayVariable;
	return addDayString;
}

string DayOfTheWeek::minusOneDay(int minusDay, int &iNum, int &dayVariable, string minusDayString){
	minusDay = iNum - 1;
	ConvertToString(minusDay);
	minusDayString = dayVariable;
	return minusDayString;
}


so how would I go about calling this function without wiping the information I need to use?
I'm puzzled.

1
2
3
4
5
6
string DayOfTheWeek::plusOneDay(int addDay, int &iNum, int &dayVariable, string addDayString){
	addDay = iNum + 1;
	ConvertToString(addDay);
	addDayString = dayVariable;
	return addDayString;
}


You're using iNum to give addDay a value, but iNum has never been set to anything and you don't attempt to pass it in when you actually (incorrectly) called the function. What do you expect iNum to be at this point?
Last edited on
Topic archived. No new replies allowed.