class - C++ - Deriving Classes - Error: expected primary expression before'int' -
first post gentle me...
i trying implement derived class , having problems , no matter try getting compilation errors. sure simple have missed new , research has given me no (or have missed cause dont know doing!).
this header file:
#ifndef weekday_h #define weekday_h #include <iostream> #include <string> #include <ctime> 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
this excerpt .cpp file trying implement:
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(){ }
at present getting following error:
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
if change things around in .cpp file different errors - obviously.
basically don't know how , have struggled trying find correct way...
anyway if can point me in right direction appreciated...
thanks
you're using member initialization list incorrectly. if want pass values of arguments passed weekday
constructor constructor of datetime
, need remove types:
weekday::weekday(int y, int m, int d, int h, int min, int s) : datetime(y, m, d, h, min, s) { }
consider calling function (because actually, that's it's doing). if have function void foo(int x);
, don't call writing foo(int 5)
, you?
Comments
Post a Comment