First I use C ++ 11 . I have a base class called Area that has an undefined pure virtual function called restart ().
Then I have two derived classes, one called AreaRectangular and another called AreaCircular .
The problem is that these, in addition to implementing their own definition of restart () , each has an additional restart () different from the other derived class: p>
AreaCircular& reiniciar(Posicion2D pos, double radio); // de AreaCircular
AreaRectangular& reiniciar(Posicion2D pos, Tamanyo2D tamanyo); // de AreaRectangular
The problem I have is that I can not invoke any of these two functions using a pointer to the base class, since the only version it recognizes is that of restart () without parameters.
I had thought about putting these two versions of restart () in the base class as well and making them pure virtual but then the derived classes inherit a method that I do not want because they force an object to return a different derived class.
In summary. How can I use a pointer to Area to invoke the reboot version () that I want depending on the type of object being pointed?
Error message:
error: no matching function for call to 'Area::reiniciar(Posicion2D&, Tamanyo2D&)'
note: candidate: virtual Area& Area::reiniciar()
note: candidate expects 0 arguments, 2 provided
I add the declaration of the base class:
// PredeClarar Clases
class AreaRectangular;
class AreaCircular;
// Clase Base
class Area
{
public:
virtual ~Area() = 0;
virtual Area& reiniciar() = 0;
virtual bool colisiona(Posicion2D pos) const = 0;
virtual bool colisiona(AreaRectangular pos) const = 0;
virtual bool colisiona(AreaCircular pos) const = 0;
virtual int getX() const = 0;
virtual int getY() const = 0;
};