fork download
  1. #include<iostream>
  2. using namespace std;
  3. class LandVehicle{
  4. public:
  5. int noOfWheels;
  6.  
  7. LandVehicle(int noOfWheels){
  8. this->noOfWheels=noOfWheels;
  9. cout<<"Constructor of land vehicle\n";
  10. }
  11.  
  12. };
  13.  
  14. class WaterVehicle{
  15. public:
  16. int draftDepth;
  17.  
  18. WaterVehicle(int draftDepth){
  19. this->draftDepth=draftDepth;
  20. cout<<"Constructor of water vehicle\n";
  21. }
  22.  
  23. };
  24.  
  25. class AmphVehicle: public LandVehicle, public WaterVehicle{
  26. public:
  27. bool canOpOnSand;
  28.  
  29. AmphVehicle(int noOfWheels, int draftDepth, bool canOpOnSand)
  30. :LandVehicle(noOfWheels), WaterVehicle(draftDepth){
  31. this->canOpOnSand=canOpOnSand;
  32. cout<<"Constructor of amphibious vehicle\n";
  33. }
  34. };
  35.  
  36.  
  37. int main(){
  38. AmphVehicle av(4, 10, true);
  39.  
  40. return 0;
  41. }
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
Constructor of land vehicle
Constructor of water vehicle
Constructor of amphibious vehicle