Note that there are some explanatory texts on larger screens.

plurals
  1. POStatic function as operand
    primarykey
    data
    text
    <p>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).</p> <p>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.</p> <p>Header file:</p> <pre><code>#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 </code></pre> <p>Implementation .cpp file(part of it):</p> <pre><code>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&gt;2){ //Diorthwsi gia ton mina flebari Days1YearLoop = *(_day1YearLoop + (setMonth-1)) + setDay + 1; Days4YearLoop = Days1YearLoop; } else{ Days1YearLoop = *(_day1YearLoop+(setMonth-1))+setDay; </code></pre> <p>Why is that happening? Isn't it supposed to work this way?</p> <p>Also inside the function dayNumberCalc should I save the returns of the static functions in local variables and use them instead of the returns?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload