I'm currently working on a project with several classes :
an abstract one :
template <typename Elem> class Vector {...}
another abstract one :
template <typename Elem> class AbsPolynom: virtual public Vector<Elem>
a inheritence from Vector :
template <typename Elem> class Dvector: virtual public Vector<Elem>
and the last one :
template <typename Elem> class Polynom: public AbsPolynom<Elem>, public Dvector<Elem>{
When I call Polynom, like this :
Polynom<int> test(std::size_t(3),3,3);
I get this error :
In file included from Polynom.cpp:6:0, from main2.cpp:4: Polynom.hpp: In instantiation of ‘Polynom::Polynom(std::size_t, const Elem&, const int&) [with Elem = int; std::size_t = long unsigned int]’: main2.cpp:10:41: required from here Polynom.hpp:14:105: error: no matching function for call to ‘Vector::Vector()’ Polynom(std::size_t dim, const Elem& value, const int& degrees ): AbsPolynom(dim, value, degrees) {};
So here is my question : Why does it call this constructor from Vector? I always have a parameter but it initializes this class without parameters
Here are my Constructors :
Polynom :
Polynom(std::size_t dim, const Elem& value, const int& degrees ): AbsPolynom<Elem>(dim, value, degrees) {};
Polynom(std::size_t dim, const Elem& value, const int degrees[] ): AbsPolynom<Elem>(dim, value, degrees) {};
Polynom(std::size_t dim, const Elem values[], const int& degrees): AbsPolynom<Elem>(dim, values, degrees) {};
Polynom(std::size_t dim, const Elem values[], const int degrees[]): AbsPolynom<Elem>(dim, values, degrees) {};
AbsPolynom :
explicit AbsPolynom(std::size_t, const Elem&, const int& );
explicit AbsPolynom(std::size_t, const Elem&, const int [] );
explicit AbsPolynom(std::size_t, const Elem [], const int& );
explicit AbsPolynom(std::size_t, const Elem [], const int [] );
template <typename Elem>AbsPolynom<Elem>::AbsPolynom(std::size_t dim, const Elem& value, const int& degrees ): Vector<Elem>(dim, value), _degrees(new Elem[dim]),_polynomDegree(degrees) {
for (std::size_t i = 0; i < dim; ++i) _degrees[i] = degrees;}
template <typename Elem>AbsPolynom<Elem>::AbsPolynom(std::size_t dim, const Elem& value, const int degrees[] ): Vector<Elem>(dim, value), _degrees(new Elem[dim]),_polynomDegree(degrees[0]) {
for (std::size_t i = 0; i < dim; ++i) _degrees[i] = degrees[i];}
template <typename Elem>AbsPolynom<Elem>:: AbsPolynom(std::size_t dim, const Elem values[], const int& degrees): Vector<Elem>(dim, values), _degrees(new Elem[dim]),_polynomDegree(degrees) {
for (std::size_t i = 0; i < dim; ++i) _degrees[i] = degrees;}
template <typename Elem>AbsPolynom<Elem>::AbsPolynom(std::size_t dim, const Elem values[], const int degrees[]): Vector<Elem>(dim, values), _degrees(new Elem[dim]),_polynomDegree(degrees[0]) {
for (std::size_t i = 0; i < dim; ++i) _degrees[i] = degrees[i];}
and Vector :
explicit Vector(std::size_t dim, const Elem& elem);
explicit Vector(std::size_t, const Elem[] );
template <typename Elem>Vector<Elem>::Vector (std::size_t dim, const Elem& elem):_dim(dim), _values(new Elem[dim]) {
for (std::size_t i = 0; i < dim; ++i) _values[i] = elem; }
template <typename Elem>Vector<Elem>::Vector ( std::size_t dim, const Elem elem[]):_dim(dim), _values(new Elem[dim]) {
for (std::size_t i = 0; i < dim; ++i) _values[i] = elem[i];
}
Vector
have a parameterless constructor? Please show the signatures ofVector
andPolynom
constructors. – Zdeslav Vojkovic