c++ - What is causing deleted function error message? -
i have main program uses 2 templates classes trans , travel, , generates compilation error use of deleted function 'makecolor::makecolor()
, , also: note: 'makecolor::makecolor()' implicitly deleted because default definition ill-formed
. how can fix this?
class travel:
#include "trans.hpp" template<typename a, typename b, typename c> class travel { public: typedef trans<a, b> cartype; typedef trans<c, int> boattype; typedef typename cartype::newest newestcar; typedef typename boattype::newest newestboat; };
class trans:
template<typename a, typename b> class trans { public: class newest; };
main program:
#include "travel.hpp" #include "trans.hpp" travel<makecolor, makematerial, makesize> struct makecolor { cartype::newestcar model; // error }; int main(){ ... }
makecolor
not have default constructor because cartype::newestcar
not have default constructor.
you'll need explicitly create constructor initializes model
.
struct makecolor { makecolor() : model( /* pass constructor parameters here */ ) {} cartype::newestcar model; // error };
Comments
Post a Comment