c++ - Multiple Inheritance from two derived classes with templates and constructors -


i'm following example here, using templates , calling constructor of 1 of derived classes. following code works without templates when included not sure why following error:

: error: no matching function call ‘absinit<double>::absinit()’      notabstotal(int x) : absinit(x) {};                                    ^ 

here code:

#include <iostream>  using namespace std;  template<typename t> class absbase {     virtual void init() = 0;     virtual void work() = 0; };  template<typename t> class absinit : public virtual absbase<t> { public:     int n;     absinit(int x)     {         n = x;     }     void init() {  } };  template<typename t> class abswork : public virtual absbase<t> {     void work() {  } };  template<typename t> class notabstotal : public absinit<t>, public abswork<t> { public:     t y;     notabstotal(int x) : absinit(x) {}; };    // nothing, both should defined   int main() {   notabstotal<double> foo(10);   cout << foo.n << endl;  } 

you need pass template-argument (in case, t) base template-class.

change this

template<typename t> class notabstotal : public absinit<t>, public abswork<t> { public:     t y;     notabstotal(int x) : absinit<t>(x) // need pass template parameter     {}; };     

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -