Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ - Deriving Classes - Error: expected primary expression before'int'
    text
    copied!<p>First post so be gentle with me...</p> <p>I am trying to implement a derived class and am having problems and no matter what i try am getting compilation errors. I am sure it is something simple i have missed but am very new to this and all my research has given me no help (or i have just missed it cause i dont know what I am doing!).</p> <p>This is my header file:</p> <pre><code>#ifndef WEEKDAY_H #define WEEKDAY_H #include &lt;iostream&gt; #include &lt;string&gt; #include &lt;ctime&gt; using namespace std; class DateTime{ public: DateTime(int y, int m, int d, int h = 0, int min = 0, int s = 0); void display(); protected: string get_string_component(char option, tm* dateStruct); int get_year_days(tm* dateStruct); struct tm DTstruct; private: bool validate_data( int y, int m, int d, int h, int min, int s); }; class WeekDay : public DateTime{ public: WeekDay(int y, int m, int d, int h = 0, int min = 0, int s = 0); void display(); }; #endif </code></pre> <p>This is an excerpt from the .cpp file that i am trying to implement:</p> <pre><code>WeekDay::WeekDay(int y, int m, int d, int h, int min, int s) : DateTime(int y, int m, int d, int h, int min, int s),{ } void WeekDay::display(){ } </code></pre> <p>At present I am getting the following error:</p> <pre><code>weekday.cpp: In constructor 'WeekDay::WeekDay(int, int, int, int, int, int)': weekday.cpp:58:13: error: expected primary-expression before 'int' weekday.cpp:58:20: error: expected primary-expression before 'int' weekday.cpp:58:27: error: expected primary-expression before 'int' weekday.cpp:58:34: error: expected primary-expression before 'int' weekday.cpp:58:41: error: expected primary-expression before 'int' weekday.cpp:58:50: error: expected primary-expression before 'int' weekday.cpp:60:1: error: expected identifier before '{' token </code></pre> <p>If i change things around in the .cpp file i get different errors - obviously.</p> <p>Basically i really don't know how to do this and have struggled trying to find the correct way...</p> <p>Anyway if someone can point me in the right direction it would be greatly appreciated...</p> <p>Thanks</p>
 

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