by Oddjob on November 3rd, 2011

Oddjob

Poll

Help answer this question below.

The AeroCar class inherits from the Car class. For the AeroCar class to override the set_speed function, what must be done?

I was confused because the class does not define the set_speed as a virtual function making it not possible to override so the last option is my choice but I know you can override with virtual, wanted to see if I was correct in my thoughts.

class Car
{
public:
Car();
void set_speed(double new_speed);
double get_speed() const;
private:
double speed;
};

Embed

Answers. 2 helpful answers below.

  • by Anonymous on November 4th, 2011
    voted: The AeroCar class cannot override the set_speed function.

    Anonymous

    it's not virtual so you can't override it.

    • Like
    • Report

    No comments. Post one | Permalink

  • by engineer is Terminator on November 4th, 2011
    voted: The AeroCar class must define the function void override_set_speed(double new_speed)

    engineer is Terminator

    You already have the answer there.The "override" key word help you override the function from parent class.

Want to attach an image to your answer? Click here.

Did this answer your question? If not, then ask a new question or create a poll.

You're reading The AeroCar class inherits from the Car class. For the AeroCar class to override the set_speed function, what must be done?

Follow us on Facebook!

Related Ads