Problem with C++ and derived class
Posted: Fri Aug 04, 2023 2:48 pm
Hello,
Above a summary of my code:
The error I have is the following:
If I create the default constructor and log both constructor, I see that only default one is called when i create prmHandler.
Where is the problem?
I obviously want to call prm(a,b,c,d,e) as i create prmHandler(a,b,c,d,e,f,g,h) , not prm().
Thanks
Above a summary of my code:
Code: Select all
///////////// .h files /////////////
class prm {
public:
prm(char * a, uint16_t b, bool c, bool d, int e);
virtual ~prm();
...
class prmHandler : public prm{
public:
prmHandler(char * a, uint16_t b, bool c, bool d, int e, std::string f, int g, int h);
~prmHandler();
std::string f;
int g, h;
...
///////////// .cpp file /////////////
prmHandler::prmHandler(char * a, uint16_t b, bool c, bool d, int e, std::string f2, int g2, int h2):
prm(a, b, c, d, e), f(f2), g(g2*1000), h(h2) {
...
I'm using IDF 5.1prmHandler.cpp: In constructor 'prmHandler::prmHandler(char*, uint16_t, bool, bool, int, std::string, int, int)':
prmHandler.cpp:13:103: error: no matching function for call to 'prm::prm()'
13 | prm(a, b, c, d, e), f(f2), g(g2*1000), h(h2) {
If I create the default constructor and log both constructor, I see that only default one is called when i create prmHandler.
Where is the problem?
I obviously want to call prm(a,b,c,d,e) as i create prmHandler(a,b,c,d,e,f,g,h) , not prm().
Thanks