Create a class Vehicle and three additional classes (each derived from Vehicle) named Car, Truck and Boat. The member attributes and functions for each class are given below. Make parametrized constructor for all classes.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Create a class Vehicle and three additional classes (each derived from Vehicle) named Car, Truck and Boat. The member attributes and functions for each class are given below. Make parametrized constructor for all classes.
Vehicle:
private:
int wheels;
float weight;
int model;
int passenger_capicty;
public:
void print_info()=0;
Car:
public:
void print_info();
Truck:
private:
float load_capicty;
public:
void print_info();
Boat:
public:
void print_info();
Trending now
This is a popular solution!
Step by step
Solved in 2 steps