C ++, by default, tends to create a base implementation of certain basic functions, which are:
- Default constructor
- Copy constructor
- Constructor move (C ++ 11)
- Destroyer
- Assignment operator
- Assignment operator move (C ++ 11)
The problem arises when specific functions are provided. In this case, the compiler stops implementing certain functions.
On the other hand, when you inherit a class the base class always has to call some constructor of the parent class. If no constructor is specified, the one that ends up being called is the default constructor as seen in the following example:
struct Base
{
Base()
{ std::cout << "Base::Base()\n"; }
}
struct Derivada : Base
{
Derivada()
{ std::cout << "Derivada::Derivada()\n"; }
}
int main()
{
Derivada d;
}
Exit:
Base::Base()
Derivada::Derivada()
In your case, when implementing a specific constructor, the compiler leaves aside the implicit implementation of the default constructor. The solution is to implement it explicitly or call a different base constructor:
Explicit implementation
class TasMin
{
public:
TasMin(){ } // Constructor por defecto explicito
TasMin() = default; // Constructor por defecto (C++11)
TasMin(int size);
};
Call an explicit base constructor:
MaxSize::MaxSize(int size)
: TasMin(size)
{ }