CS304 Assignment 2 Solution 2023

Hey there, welcome to the post about CS304 Assignment 2 Solution 2023! If you’re on the hunt for the perfect solution to your CS304 Assignment 2 in the Spring 2023 semester at Virtual University, you’ve come to the right spot.

This post has got you covered! We’ve prepared a comprehensive and well-crafted solution that’ll help you excel in your academics. Whether you searched for “CS304 Assignment 2 2023,” “CS304 Assignment 2 2023 Solution,” “CS304 Assignment 2 Solution 2023,” or simply “CS304,” don’t worry, we’ve got all the answers right here. So, let’s dive in together and uncover the secrets to acing this assignment and achieving success in your CS304 course at Virtual University!

Related Posts:

Solution

#include<iostream>

// Solution by Topics Learn
using namespace std;
class Vehicle{
	int vehicleID;
	float maxSpeed;
	public:
		Vehicle()
		{
		vehicleID= 6963;
		maxSpeed= 80;	
		}
		void displayVehicleDetails() const
		{
			cout<<"vehicle ID:"<<vehicleID<<endl;
			cout<<"max speed:" <<maxSpeed<<"km/h"<<endl;
		}
		
};
class PassengerVehicle: public  virtual Vehicle
{
public:
      void transportPassengers() const
	  {
	  	cout<<"transporting passengers:"<<endl;
		  }	
};
class GoodsVehicle:public virtual Vehicle
{
	public:
		void transportGoods() const
		{
			cout<<"transporting goods:"<<endl;
		}
};
class Truck:public  PassengerVehicle, public GoodsVehicle
{
	public:
		void town() const
		{
		cout<<"truck is towing:"<<endl;	
		}
		
};

int main()
{
	Truck *t= new Truck();
	t->displayVehicleDetails();
    t->transportPassengers();
    t->transportGoods();
    t->town();	
	return 0;
}