Concept explainers
Examine the following class declarations:
class Van
{
protected:
int passengers; public:
Van(int p)
{ passengers = p; }
};
class FourByFour
{
protected:
double cargoWeight;
public:
FourByFour(float w)
{ cargoWeight = w; }
};
Write the declaration of a class named SportUti1ity. The class should be derived from both the Van and FourByFour classes above. (This should be a case of multiple inheritance, where both Van and FourByFour are base classes.)
Want to see the full answer?
Check out a sample textbook solutionChapter 15 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Additional Engineering Textbook Solutions
Starting Out with Python (4th Edition)
Concepts Of Programming Languages
Java: An Introduction to Problem Solving and Programming (8th Edition)
Modern Database Management (12th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
- Implement the Seller class as a derived class of Person class. Create the seller.h and seller.cppfiles for this class. The Seller class contains additional data members that hold a seller’s:o average star rating received from the buyers, ando total number of items sold.These data should be accessible by its derived classes. (should these data be private, public, orprotected?) The following methods are included in the seller class:• A default constructor and a copy constructor• A constructor that receives all of the data for a seller.(for the constructors, make sure to call the base class constructor as appropriate)• Appropriate get and set functions for the new data in this class• print() – overrides the base class print() to print the base class data and print all additionalseller data with appropriate messages. Make sure to call the base class print to print thebase class data.• read() – overrides the base class read() to read the base class data and reads all additionalseller data…arrow_forwardUse the following partial class definitions to answer the questions a-c public class A1 { public int x; private int y; protected int z; ... } public class A2 extends A1 { protected int a; private int b; ... } public class A3 extends A2 { private int q; ... } a) Which of the following is true with respect to A1, A2 and A3? Group of answer choices A1 is a subclass of A2 and A2 is a subclass of A3 A3 is a subclass of A2 and A2 is a subclass of A1 A1 and A2 are both subclasses of A3 A2 and A3 are both subclasses of A1 A1, A2 and A3 are all…arrow_forwardPLZ help wiith the following: IN JAVA If an inner class contains non static members, then the class name must be modified by the keyword: Final Static Void Protectedarrow_forward
- Complete the thick.h, thick.cpp, thin.h, and thin.cpp classes in the attached pizza solution. Modify your main.cpp class so that it creates a thin and thick crust pizza if selected by the user. Your solution should allow the user to order a regular, stuffed, thin or thick crust pizza. All child classes (stuffed, thin, thick) should inherit attributes and functions from the Pizza class. The stuffed class has already been implemented. The thick and thin class set_cost() funtions should differ in the following ways: thick crust has an additional charge of $2 thin crust has a cost discount of $1arrow_forwardHow many default constructors can a class have? a. A class cannot have a default constructor. b. only one c. as many as it needs d. one or more, but fewer than threearrow_forwardWrite a class Distance which has two private data members (int feet,float inches). The class has three constructors which are having no parameter - values of both feet and inches are assigned zero. having two numbers as parameters - the two numbers are assigned as feet and inches respectively. having one number as parameter - both feet and inches are assigned that number. Provide getters and setters for data members. Now write a main class which demonstrate the functionality of above class by calling all constructors, setters & getters. Create 1 object using default constructor, and use setters to set values, then getters to print values. Create a second object using constructor having two parameters, provide values, then print values on screen. Create third object by using third constructor having one parameter, after that print values on screen.arrow_forward
- Examine the following code and select the correct statements (choose all possibleoptions): class Bottle {Bottle() {}Bottle(WaterBottle w) {}}class WaterBottle extends Bottle {WaterBottle() { }WaterBottle(Bottle w) { } } a) The class Bottle defines two overloaded constructors.b) The class WaterBottle defines two overloaded constructors.c) The class compiles successfully—a base class can use reference variables of its derived class as method parameters.d) Bottle and WaterBottle cause syntax errors.e) The class compiles successfully - A derived class can use reference variables of its base class as method parameters.f) A base class can’t pass reference variables of its defined class, as method parameters in constructors.arrow_forwardQ2 Your code must ensure that all the relevant classes Seller, Dealer, Buyer, and distinct classes Animal and Invoice implement a common method for maintaining the finances. Details of the classes can be seen in Table 1. Explain with proper syntax as to how this can be achieved using object-oriented programming, highlighting the changes you will need to make in the class declarations in Question 1 Q1 code is down below package com.company.sale;public class Animal {int tag;double price,weight,serviceCharge;String color,date;Boolean sold;public static void main(String[] args) {Animal Cow=new Animal();}}class Dealer extends Animal{String dname,address;double commission,earning;long pno,id;void earning(){return earning;}}class Seller{String name,address;long id;double profitRate,salesTax,profit;void SalesTaxProfit(){return profit*salesTax/100;}}class Buyer{String name,address;long id,contact;double amt;void amt(){return amt;}}arrow_forwardMark the following statements as true or false. The member variables of a class must be of the same type. (1) The member functions of a class must be public. (2) A class can have more than one constructor. (5) A class can have more than one destructor. (5) Both constructors and destructors can have parameters. (5)arrow_forward
- Analysis the following class definition and answer the following question. class Student{ private int id, age; protected float mark; int getAge (int a){ return a ; } protected void setMark (float m){ mark = m; } float result(){ return mark / 2; } } Which is the member variable of the class? a. setMark b. getAge c. result d. private e. agearrow_forwardA class is made abstract by declaring that class virtual. T/Farrow_forwardFill the gap: The________declares that a derived class is allowed to override a method.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr