I have made some static functions in order to call them without making any object of the class they belong to. I have included the header file of the class with the static functions (NTP.h) into another class (DayNumber).
I want to place the returns of some functions as operants of a functions of DayNumber class. I get error that NTP has not been declared. Here it is the code.
Header file:
#include "NTP.h"
class DayNumber{
private:
int _day1YearLoop[];
int _day4YearLoop[];
public:
int Days1YearLoop;
int Days4YearLoop;
DayNumber();
void dayNumberCalc( NTP::getYear(),NTP::getMonth(),NTP::getDate());
virtual ~DayNumber();
bool checkLeapYear(int setYear);
};
#endif
Implementation .cpp file(part of it):
void DayNumber::dayNumberCalc( NTP::getYear(), NTP::getMonth(), NTP::getDate()){
int setYear = NTP::getYear();
int setMonth = NTP::getMonth();
int setDay = NTP::getDate();
//Days that passed from the beginning of the year for the first day each month
int _day1YearLoop[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
//i= _day1YearLoop;
//Days that passed from the beginning of the second year since the 'for'.
//The first day of the running year in a four-years loop.
int _day4YearLoop[]={366,731,1096};
if (checkLeapYear(setYear)){
if (setMonth>2){ //Diorthwsi gia ton mina flebari
Days1YearLoop = *(_day1YearLoop + (setMonth-1)) + setDay + 1;
Days4YearLoop = Days1YearLoop;
}
else{
Days1YearLoop = *(_day1YearLoop+(setMonth-1))+setDay;
Why is that happening? Isn’t it supposed to work this way?
Also inside the function dayNumberCalc should I save the returns of the static functions in local variables and use them instead of the returns?
The syntax for your function declaration is incorrect:
You’re supposed to list the argument types and names here. Perhaps you wanted:
Then you would call it with:
Alternatively, if you want the static members of
NTPto be called from withindayNumberCalc, give it no arguments:Or, if you want to have arguments that have default values given by the static functions, do: