Concept explainers
Write the declaration for class B. The class’s members should be as follows:
• m: an integer. This variable should not be accessible to code outside the class or to member functions in any class derived from class B.
• n: an integer. This variable should not be accessible to code outside the class, but should be accessible to member functions in any class derived from class B.
• setM, getM, setN, and getN: These are the set and get functions for the member variables m and n. These functions should be accessible to code outside the class.
• cal c: a public virtual member function that returns the value of m times n.
Next, write the declaration for class D, which is derived from class B. The class’s members should be as follows:
• q: a float. This variable should not be accessible to code outside the class but should be accessible to member functions in any class derived from class D.
• r: a float. This variable should not be accessible to code outside the class, but should be accessible to member functions in any class derived from class D.
• setQ, getQ, setR, and getR: These are the set and get functions for the member variables q and r. These functions should be accessible to code outside the class.
• calc: a public member function that overrides the base class calc function. This function should return the value of q times r.
Want to see the full answer?
Check out a sample textbook solutionChapter 15 Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Additional Engineering Textbook Solutions
Database Concepts (8th Edition)
Database Concepts (7th Edition)
Starting Out with Python (4th Edition)
Starting Out with Java: Early Objects (6th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
- ngineering Computer ScienceQ&A Libraryin c++ Create a class time24, each object is a value represented the time of day in the form hours, minutes and seconds. Provide a constructor that enables an object of this class to be initialized when it is instantiated. The constructor should contain default values in case no initializes are provided. Provide Public member functions for each of the following operations: set the time, print the time, increment the time by one second, compare two times for equality, increment the time by one hour, determine if one time is “less than” (comes before) another time, and final print the time in format 12 hours. Include any additional operations that you think would be useful for your class. Design, implement, and test your class. in c++ Create a class time24, each object is a value represented the time of day in the form hours, minutes and seconds. Provide a constructor that enables an object of this class to be initialized when it is…arrow_forwardC++ True/False: a member function in a class can access all of its class's member variables, but not if the variables are private.arrow_forwardCar Class in C++ language whole task is in the picturearrow_forward
- writte in c++ Write a Circle class that has the following member variables: • radius : a double • pi : a double initialized with the value 3.14159 The class should have the following member functions: • Default Constructor. A default constructor that sets radius to 0.0. • Constructor. Accepts the radius of the circle as an argument. • setRadius. A mutator function for the radius variable. • getRadius. An accessor function for the radius variable. • getArea. Returns the area of the circle, which is calculated as area = pi * radius * radius • getCircumference. Returns the circumference of the circle, which is calculated as circumference = 2 * pi * radiusarrow_forward8. Circle ClassWrite a Circle class that has the following member variables:• radius: a double• pi: a double initialized with the value 3.14159The class should have the following member functions:• Default Constructor. A default constructor that sets radius to 0.0.• Constructor. Accepts the radius of the circle as an argument.• setRadius. A mutator function for the radius variable.• getRadius. An accessor function for the radius variable.• getArea. Returns the area of the circle, which is calculated as area = pi * radius * radius• getDiameter. Returns the diameter of the circle, which is calculated as diameter = radius * 2• getCircumference. Returns the circumference of the circle, which is calculated as circumference = 2 * pi * radiusWrite a program that demonstrates the Circle class by asking the user for the circle’s radius, creating a Circle object, and then reporting the circle’s area, diameter, and circumference.…arrow_forwardC++ Friend function concepts Do not use operator overloading Create a class User with private member variables "id". In the class define a function increment_user_id() which will increment the id and return it as well. Create another method "void show_Id()" to show the id for a particular object. Create a constructor of User class where increment the Id by calling the increment_user_id() method for every new object . Finally create two objects of the class and print their corresponding id's on console.arrow_forward
- Java:arrow_forwardStatic Data member and Friend Function Q#01: In this assignment you will be creating a class named Employee. Employee class has the following data members: Employee ID. Employee Name Department Employee Salary Static data member which will hold the value of total no. of employees Employee class must have the following member functions: Function Description Employee() Default constructor for Employee class, which will set employee id to 0, employee name to NULL, employee department to NULL and salary to 0.0 Employee(int, char *, char *, float); It will take employee id, employee name, department and salary as arguments and initialize their values using member initializer list Employee(Employee &); Copy constructor which will initialize one object with another object using deep copy Setter functions You have to define setter function for each data member which will take a value as an argument and set their values Getter functions You have…arrow_forwardC++ Write a Cuboid class that has the following member variables: • length (l) • width (w) • height (h) The class should have the following member functions: • Default Constructor: A default constructor that sets length, width, and height all to 1.0. • Another Constructor: Accepts the length, width, and height of the cuboid as arguments. • getV: Returns the volume of the cuboid.• getS: Returns the surface area of the cuboid. • A Destructor: Print e.g. Cuboid(1.0 x 2.3 x 5.6) is deleted.. The number is the length, width and height of the cuboid.arrow_forward
- This type of member function may be called from a function that is a member of the same class or a derived class. static private protected O None of thesearrow_forwardc++ languagearrow_forwardProgram SpecificationUsing python, design a class named PersonData with the following member variables: lastName firstName address city state zip phone Write the appropriate accessor and mutator functions for these member variables. Next, design a class named CustomerData , which is derived from the PersonData class. The CustomerData class should have the following member variables: customerNumber mailingList The customerNumber variable will be used to hold a unique integer for each customer. The mailingList variable should be a bool . It will be set to true if the customer wishes to be on a mailing list, or false if the customer does not wish to be on a mail-ing list. Write appropriate accessor and mutator functions for these member variables. Next write a program which demonstrates an object of the CustomerData class in a program. Your program MUST use exception handling. You can choose how to implement the exception handling. Start your program with a welcome message Make sure…arrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,