C++ PROGRAMMING:FROM...(LL) >CUSTOM<
8th Edition
ISBN: 9780357019528
Author: Malik
Publisher: CENGAGE C
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 13, Problem 15SA
Explanation of Solution
The function prototypes (declarations) of the different operators in the class definition are given below:
class strange
{
//part (a)
friend strange operator+(const strange&, const strange&);
...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
SUBJECT: OOPPROGRAMMING LANGUAGE: C++
ALSO ADD SCREENSHOTS OF OUTPUT.
Write a class Distance to measure distance in meters and kilometers. The class should have appropriate constructors for initializing members to 0 as well as user provided values. The class should have display function to display the data members on screen.
Write another class Time to measure time in hours and minutes. The class should have appropriate constructors for initializing members to 0 as well as user provided values. The class should have display function to display the data members on screen.
Write another class which has appropriate functions for taking objects of the Distance class and Time class to store time and distance in a file.
Make the data members and functions in your program const where applicable
a. What is the return type of the function that overloads the binary operator || (or) for a class as a member function of the class? b. What is the return type of the function that overloads the binary operator || (or) for a class as a nonmember function of the class?
c++ exercise:
1- Implement the class “cylinder” with member variables radius and height, whichare private of type double. Define the global constant PI=3.1415 and use it incalculating the volume of the cylinder (PI*radius*radius*height).Implement in the class cylinder the following functions:a- A default constructor with default values of one.b- One constructor with two arguments. This constructor should check that thevariable is positive and does not exceed 20, otherwise the variable will beassigned its default value of one.c- A reader for each variable.d- A writer for each variable.e- A reader and a writer for diameter.f- A member function “volume” which calculates the volume of a cylinder.g- A member function “print” which prints the radius, diameter, and height of acylinder.h- A member function display_name() which displays “cylinder
Chapter 13 Solutions
C++ PROGRAMMING:FROM...(LL) >CUSTOM<
Ch. 13 - Prob. 1TFCh. 13 - What are the two things that you need to overload...Ch. 13 - Which of the following operator cannot be...Ch. 13 -
a. Within the definition of an operator function,...Ch. 13 - Prob. 5SACh. 13 -
What is the difference between a friend function...Ch. 13 - Prob. 7SACh. 13 - Prob. 8SACh. 13 -
Suppose that the binary operator + is overloaded...Ch. 13 - Prob. 10SA
Ch. 13 - Prob. 11SACh. 13 -
Suppose that the binary operator + is overloaded...Ch. 13 - Prob. 13SACh. 13 -
Consider the following declaration: (6) class...Ch. 13 - Prob. 15SACh. 13 -
Ch. 13 -
Find the error(s) in the following code: (6)
Ch. 13 - Prob. 18SACh. 13 - Prob. 1PECh. 13 - Redo Programming Exercise 1 by overloading the...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- C++ True or False (True → CAN be accessed, False → CANNOT be accessed) П П A private variable declared in class ABC CAN be accessed: m. From a member function of class ABC? n. From a member function of a child class of ABC? o. From a friend function of class ABC, accessed using the dot operator? p. From a member function of a friend class of ABC, accessed using the dot operator? q. From an otherwise unrelated class that declares ABC to be its' friend, accessed using the dot operator? r. From main, accessed using the dot operator?arrow_forwardC++ True or False (True → CAN be accessed, False → CANNOT be accessed) A protected variable declared in class ABC CAN be accessed: g. From a member function of class ABC? h. From a member function of a child class of ABC? i. From a friend function of class ABC, accessed using the dot operator? - j. From a member function of a friend class of ABC, accessed using the dot operator? k. From an otherwise unrelated class that declares ABC to be its' friend, accessed using the dot operator? - I. From main, accessed using the dot operator? A private variable declared in class ABC CAN be accessed: m. From a member function of class ABC? n. From a member function of a child class of ABC? o. From a friend function of class ABC, accessed using the dot operator? p. From a member function of a friend class of ABC, accessed using the dot operator? q. From an otherwise unrelated class that declares ABC to be its' accessed using the dot operator? nd, r. From main, accessed using the dot operator?arrow_forwardCreate a class Test with two private integer data members: x and y and one member function: getdata() for taking input of x and y. Create two non-member friend functions: task1() and task2() to class Test, such as task1() is displaying squares of integers from 1 to x and task2() is finding the sum of all integers from 1 to y. in c++ onlyarrow_forward
- Please solution in c++arrow_forwardc++arrow_forwardC++ True or False (True → CAN be accessed, False → CANNOT be accessed) A public variable declared in class ABC CAN be accessed: a, From a member function of class ABC? b. From a member function of a child class of ABC? c. From a friend function of class ABC, accessed using the dot operator? d. From a member function of a friend class of ABC, accessed using the dot operator? e. From an otherwise unrelated class that declares ABC to be its' friend, accessed using the dot operator? f. From main, accessed using the dot operator? A protected variable declared in class ABC CAN be accessed: g. From a member function of class ABC? - h. From a member function of a child class of ABC? i. From a friend function of class ABC, accessed using the dot operator? j. From a member function of a friend class of ABC, accessed using the dot operator? k. From an otherwise unrelated class that declares ABC to be its' friend, accessed using the dot operator? I. From main, accessed using the dot operator? A…arrow_forward
- Write a C++ code for the following question as quickly as you can. But please do the same as asked in the Question...arrow_forwardWrite a class Box having three private data members (width, depth, height) The class has three constructors which are having no parameter – for setting values to zero or null. having three parameters for assigning values to height, width, depth respectively. Overload the above constructor and use this keyword to set the values of width, height & depth. Provide getters/setters for data members. Write a function calculateVolume() which calculates the volume of the box. Write test Application that demonstrates the Box class by calling all the three constructors and method, creating a Create Box object, and then displaying the Box’swidth , height, length and volume .arrow_forwardDefine a Pet class that stores the pet’s name, age, and weight. Add appropriateconstructors, accessor functions, and mutator functions. Also define a functionnamed getLifespan that returns a string with the value “unknown lifespan.” Next, define a Dog class that is derived from Pet. The Dog class should have aprivate member variable named breed that stores the breed of the dog. Add mutator and accessor functions for the breed variable and appropriate constructors.Redefine the getLifespan function to return “Approximately 7 years” if the dog’sweight is over 100 pounds and “Approximately 13 years” if the dog’s weight isunder 100 pounds. Next, define a Rock class that is derived from Pet. Redefine the getLifespanfunction to return “Thousands of years.” Finally, write a test program that creates instances of pet rocks and pet dogs thatexercise the inherited and redefined functions. use c++arrow_forward
- C++ OOP use classes only..arrow_forwardC++ :: 14. assume the definition of class temporary as given in exercise 13. answer the following questions. (1, 2, 3, 5, 7) a. write the definition of the member function set so that the instance variables are initialized according to the parameters. b. write the definition of the member function manipulate that returns a decimal number as follows: if the value of description is "rectangle", it returns first * second; if the value of description is "circle", it returns the area of the circle with radius first; if the value of description is "sphere", it returns the volume of the sphere with radius first; if the value of description is "cylinder", it returns the volume of the cylinder with radius first and height second; otherwise it returns the value -1. c. write the definition of the function print to print the values of instance variables and the values returned by the function manipulate. for example, if description = "rectangle", first = 8.5, and second = 5, it should print:…arrow_forwardAssume that dog and cat are instances of the Pet class, which has overloaded the = operator. Rewrite the following statement so it appears in function call notation instead of operator notation: dog = cat;arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
What Are Data Types?; Author: Jabrils;https://www.youtube.com/watch?v=A37-3lflh8I;License: Standard YouTube License, CC-BY
Data Types; Author: CS50;https://www.youtube.com/watch?v=Fc9htmvVZ9U;License: Standard Youtube License