I am implementing a list class with node and iterator, that creates a list of type Ticket, which is an object that i have defined in a class, but when i try to compile it says t
When you don't include code to initialize a base class in the initialization list of a constructor of a derived class, the base class is initialized using the default constructor. In other words,
List::List()
{
}
is equivalent to:
List::List() : Ticket()
{
}
Since Ticket
does not have a default constructor, the compiler does not have any way to initialize Ticket
from the posted code.
You can resolve this problem by one of the following methods:
Ticket
Update List::List()
to use the only constructor of Ticket
in the initialization list.
List::List() : Ticket(0, 0, 0) // You need to figure out what values
// make sense in your application.
{
}
Ticket
doesn't have a default constructor, therefore List
can't be default-constructed since it inherits from Ticket
, and List
does not call a base constructor in Ticket
.