0

So I have one problem and I put in the code for you to see. This is the code that i am having problems with:

int main (void){
	FancyDateClass myDateObj(24, 2, 2008);

	
	cout << "\n\n";
	cout << "The date is ";  
	myDateObj.displayDate();
	cout << "\n\n";
	cout << "The month for ";
	myDateObj.displayDate();
	cout << " is ";
	cout << myDateObj.getMonth();
	cout << "\n\n";
	cout << "The day of the week for ";
	myDateObj.displayDate();
	cout << " is ";
	cout << myDateObj.getDayOfWeek();
	cout << "\n\n";
	cout << "This date ";
	myDateObj.displayDate();
	myDateObj.isLeapYear();
	cout << "\n\n";
	cout << myDateObj.subtract();
	cout << "\n\nClosing down the program\n";



	return 0;
}
int FancyDateClass::subtract(FancyDateClass &aDateObj){
	aDateObj.setDate(25, 2, 2008);
	day = (FancyDateClass::julianDate() - aDateObj.julianDate());
	return day;
}

And here is the error that it is giving me:
1>c:\users\randy\documents\visual studio 2008\projects\cpetersonweek5lab05exercise1and2\cpetersonweek5lab05exercise1and2\inheritancecrp.cpp(62) : error C2660: 'FancyDateClass::subtract' : function does not take 0 arguments

The error it is refereeing to is on line 23 as you see in the snippet.

Now I know that I need something in the parenthesis to make it work, however I do not know what. I've tried several different options and they all come back with errors. I've searched and still not found any answers. If someone could just lead me in the right direction. If you need the full code let me know and I will post it.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Ancient Dragon
1

Look at line 30 of the code snippet you posted. See -- it has one parameter. Now look at line 23 ... there is no parameter. That's what the compiler is complaining about. You need to pass by reference the object you want to subtract.

You need to create another FancyDateClass object and pass that as the parameter. And delete line 31 -- that should be done when you create the FancyDateClass object in main. Better still you should get the current date and initialize FancyDateClass object with that instead of hard-coding some fictitious date.

Edited by Ancient Dragon: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.