some more content
This commit is contained in:
23
OOP/inheritance/Vehicle.cpp
Normal file
23
OOP/inheritance/Vehicle.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Vehicle {
|
||||
public:
|
||||
string brand = "Ford";
|
||||
void honk() {
|
||||
cout << "Honk Honk!";
|
||||
}
|
||||
};
|
||||
|
||||
class Car: public Vehicle {
|
||||
public:
|
||||
string model = "Mustang";
|
||||
};
|
||||
|
||||
int main() {
|
||||
Car myCar;
|
||||
myCar.honk();
|
||||
cout << myCar.brand + " " + myCar.model << "\n";
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user