Garmaine Staff asked 1 year ago

I'm trying to write a function parkVehicle(), this function has to access the read member function of the derived class through a Base class pointer. How can I access it?

class Parking {
     const int MAX_SPOTS_NO = 100;
    Base B[MAX_SPOTS_NO];
    void parkVehicle() const;

}


class Base : public Read {
    std::istream& read(std::istream& istr = std::cin);
}

class derived : public Base {
    std::istream& read(std::istream& istr = std::cin);
}


class Read{
virtual std::istream& read(std::istream& istr = std::cin) = 0; 
}



void parkVehicle() {
    //call read from the derived class
}