Of the three options you give, what you didn't write was the one declared.
The declaration is:
int DateToInt (Date dateToConvert);
...as a member of Date. Currently there is a logical problem, but ignoring that for a moment, this can only be called with:
newYearsDay = holiday.DateToInt( holiday );
This is required because the declared function requires a Date parameter, passed by value.
You'll note just looking at it, that makes no real sense. There should not have to be two "holidays" provided.
Since this is a member function, it must be called on an instance (as in holiday.DateToInt(...whatever...))
However, you should change the declaration so it does not require a parameter. It should act on the instance, something like this:
1 2 3 4 5
|
int DateToInt ()
{
int convertedDate = (year * 10000 + month * 100 + day);
return convertedDate;
}
|
Then, you can call it with your first attempt:
newYearsDay = holiday.DateToInt();
This will operate on the instance, and that instance provides the year, month and day values upon which to calculate the return.
I assume that is calculated as you require, though it is non-standard - no matter, you're experimenting.
Now, about this form:
holiday.DateToInt;
This prompted the error message relative to the title of your post, and may have been quite confusing. This is how one obtains a pointer to a function. It can't be used in this way, but the point is that without the () following the name, you are telling the compiler to give you the address of the member function.
It is, one might say, and advanced feature you are not ready to use, yet.
The parenthesis () following such an identifier is actually an operator, the function operator. Without it, you're referring to the address of the function, but with it you're calling the function (or attempting to).
If course, the meaning of () changes with context. It isn't a function operator when used with an "if", "for" or "while", or other similar constructs. When used in a declaration or definition, it encloses the parameter list.
It becomes the "function" or "function call" operator when it appears in the context of an indentifer, like DateToInt.