All submissions

Vehicle Inheritance Public

#include <iostream>
using namespace std;

class Vehicle {
public:
    void printCategory(){
        cout << "Generic Vehicle\n";
    }
};

class Car : public Vehicle{
public:
    void printCar(){
        cout << "Car Vehicle\n";
    }

};

int main() {
    Car c;
    c.printCategory(); // inherited method
    c.printCar();      // derived method
    return 0;
}
Loading...

Input

Expected Output

Generic Vehicle Car Vehicle