Concept explainers
FeetInches Class Copy Constructor and multiply Function
Add a copy constructor to the FeetInches class. This constructor should accept a FeetInches object as an argument. The constructor should assign to the feet attribute the value in the argument’s feet attribute, and assign to the inches attribute the value in the argument’s inches attribute. As a result, the new object will be a copy of the argument object.
Next, add a multiply member function to the FeetInches class. The multiply function should accept a FeetInches object as an argument. The argument objects feet and inches attributes will be multiplied by the calling object’s feet and inches attributes, and a FeetInches object containing the result will be returned.
Want to see the full answer?
Check out a sample textbook solutionChapter 14 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Additional Engineering Textbook Solutions
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Modern Database Management
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Mechanics of Materials (10th Edition)
Starting Out With Visual Basic (8th Edition)
- 8. 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_forwardTrue or false The arguments passed to member functions by reference are considered as data members of class.arrow_forwardFill-in-the-Blank A destructor is a member function that is automatically called when an object is_________.arrow_forward
- Using C++ programming language in object oriented programming in C++ concept Create a class called time that has separate int member data for hours, minutes, and seconds.One constructor should initialize this data to 0, and another should initialize it to fixedvalues. Another member function should display it, in 11:59:59 format. The final member function should add two objects of type time passed as arguments.arrow_forwardPROGRAMMING LANGUAGE: C++ Create a class Player with data members: first name, last name, number of matches and nationality. Derive two classes SoccerPlayer and CricketPlayer from Player.The class SoccerPlayer should have the following members: a variable to store the number of goals the player has scored and a variable to store the position on which the player plays. The class should also have a member function to compute the average number of goals scored per match.The class CricketPlayer should have variables to store the numb er of runs, thenumber of wickets and the number of catches a player has taken. Provide memberfunctions to compute the average runs scored and average wickets taken per matchby a player.Derive two classes Batsman and Bowler from the class CricketPlayer. For bats men,also store the total number of balls faced, number of 100s and number of 50s. Forbowlers, store the number of balls bowled and runs conceded. For bats men providea function to compute runs scored…arrow_forwardPS: see image for question.arrow_forward
- Static 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_forwardDefine a class called student that has thefollowing data members: - int student number- string student name- double student averageThe following member functions:- Constructor that initialize the datamembers with default values. - set and getfunctions for each data member- Print function to print the values of data members.Define a class called graduatestudent that inheritsdata members and functions from the class student,and then declare the following data members :- int level- int yearMember functions:- constructor -set and get functions for each data member- Print function.Define a class called master that inherits data members andfunctions from graduatestudent class, and then declare thefollowing data member: - int newid.Member function:- constructor- set and get function for the data member- Print function.Write a driver program that:- Declare object of type student withsuitable values then print it - Declare objectof type master with your information thenprint it. C++arrow_forwardQ3\Write an OOP complete Program to represent a car, the class constructor will set the values to all its data members, then create a member function to display the car price? Data members for car[ name, model, price, speed, color ]. Not: Class with (class interface, constructor, overloading constructor, destructor, functions and pointers)arrow_forward
- Double Bubble For this exercise you need to create a Bubble class and construct two instances of the Bubble object. You will then take the two Bubble objects and combine them to create a new, larger combined Bubble object. This will be done using functions that take in these Bubble objects as parameters. The Bubble class contains one data member, radius_, and the corresponding accessor and mutator methods for radius_, GetRadius and SetRadius. Create a member function called CalculateVolume that computes for the volume of a bubble (sphere). Use the value 3.1415 for PI. Your main function has some skeleton code that asks the user for the radius of two bubbles. You will use this to create the two Bubble objects. You will create a CombineBubbles function that receives two references (two Bubble objects) and returns a Bubble object. Combining bubbles simply means creating a new Bubble object whose radius is the sum of the two Bubble objects' radii. Take note that the CombineBubbles function…arrow_forwardA data member or member function that has a OC A. pointer B. public C. private D. protected access specifier can be accessed within the class it has been defined in and any of its derived classes.arrow_forwardA class student has rollno. ,Name, class internal exam sub1mark, sub2marks, class external has sub1marks and sub2marks and class result has total as data members write necessary member function to input and print data . (i) calculate internal exam and external exam subtotal using their respective member function (ii) class result has a function to calculate total = intetnal + external subtotalarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT