I want to try coding for real life example. I want to write code for OOP features in C++ language. Vehicle is most common example to learn object oriented programming. I want to use vehicle example to learn coding for encapsulation, inheritance and polymorphism
Vehicles: bicycle, bike, car, bus, truck, train, aircraft
Common Vehicles
: (car, bus, truck)
All Vehicles have some similarities
Common Vehicles: wheels, breaks, steering wheel
Every car have wheels, breaks, steering wheel
Every bus have wheels
breaks, steering wheel
Every truck have wheels
breaks, steering wheel
All vehicles are different from each other
Vehicles Property:
speed, wheel size, window size, fuel capacity.
Speed of vehicles may be different then other vehicles
Wheel size of vehicles may be different then other vehicles
Window size of vehicles may be different then other vehicles
Fuel capacity of vehicles may be different then other vehicles
I have define class vehicle
All those three are the object of class
Vehicles
inheritance Examples
: a car is vehicle, truck is vehicle but car is not a truck
Polymorphism
I am looking assistance who can guide me.
I am struggling to convert idea into coding. How to convert real time idea into coding
john
Vehicles: bicycle, bike, car, bus, truck, train, aircraft
Common Vehicles
: (car, bus, truck)
All Vehicles have some similarities
Common Vehicles: wheels, breaks, steering wheel
Every car have wheels, breaks, steering wheel
Every bus have wheels
breaks, steering wheel
Every truck have wheels
breaks, steering wheel
All vehicles are different from each other
Vehicles Property:
speed, wheel size, window size, fuel capacity.
Speed of vehicles may be different then other vehicles
Wheel size of vehicles may be different then other vehicles
Window size of vehicles may be different then other vehicles
Fuel capacity of vehicles may be different then other vehicles
I have define class vehicle
Code:
class Vehicles {
Wheels
breaks,
steering wheel
}
};
Vehicles
inheritance Examples
: a car is vehicle, truck is vehicle but car is not a truck
Code:
class Vehicles {
Wheels
breaks,
steering wheel
}
class Car : public Vehicles{
Wheels
breaks,
steering wheel
}
};
Code:
class Vehicles {
Wheels
breaks,
steering wheel
}
class Car {
Wheels
breaks,
steering wheel
}
};
I am looking assistance who can guide me.
I am struggling to convert idea into coding. How to convert real time idea into coding
john