EBK C PROGRAMMING:
8th Edition
ISBN: 9780357156025
Author: Malik
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Question
Chapter 13, Problem 1PE
Program Plan Intro
Overloading Operators in rectangleType class
The following C++ program defines a class rectangleType and overloads various operators.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
This chapter uses the class rectangleType to illustrate how to overload the operators +, *, ==, !=, >>, and <<. In this exercise, first redefine the class rectangleTypeby declaring the instance variables as protected and then overload additional operators as defined in parts 1 to 3.
Overload the pre- and post-increment and decrement operators to increment and decrement, respectively, the length and width of a rectangle by one unit. (Note that after decrementing the length and width, they must be positive.)
Overload the binary operator – to subtract the dimensions of one rectangle from the corresponding dimensions of another rectangle. If the resulting dimensions are not positive, output an appropriate message and do not perform the operation.
The operators == and != are overloaded by considering the lengths and widths of rectangles. Redefine the functions to overload the relational operator by considering the areas of rectangles as follows: Two rectangles are the…
Implement a nested class composition relationship between any two class types from the following list:
Advisor
Вook
Classroom
Department
Friend
Grade
School
Student
Teacher
Tutor
Write all necessary code for both classes to demonstrate a nested composition relationship including the following:
a. one encapsulated data member for each class
b. inline default constructor using constructor delegation for each class
c. inline one-parameter constructor for each class
d. inline accessors for all data members
e. inline mutators for all data members
Redo Programming Exercise 3 by overloading the operators as nonmembers of the class boxType. Write a test program that tests various operations on the class boxType.
Chapter 13 Solutions
EBK C PROGRAMMING:
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
Similar questions
- shows the complete anagram.cpp program. Use a class to represent the word to be anagrammed. Member functions of the class allow the word to be displayed, anagrammed, and rotated. The main() routine gets a word from the user, creates a word object with this word as an argument to the constructor, and calls the anagram() member function to anagram the word.arrow_forwardRedo Programming Exercise 3 by overloading the operators as nonmembers of the class boxType. Write a test program that tests various operations on the class boxType. Reference: Chapter 11 defined the class boxType by extending the definition of the class rectangleType. In this exercise, derive the class boxType from the class rectangleType, defined in Exercise 1, add the functions to overload the operators +,–, *, ==, !=, <=, <, >=, >, and pre- and post-increment and decrement operators as members of the class boxType. Also overload the operators << and >>. Overload the relational operators by considering the volume of the boxes. For example, two boxes are the same if they have the same volume. Write the definitions of the functions of the class boxType as defined above and then write a test program that tests various operations on the class.arrow_forwardC++ is a programming language that can be used to Make a program that calculates the volume of different containers. Cylinder will be the base class, and its derived classes, also known as child classes or sub-classes, will be constructed. Create a parent class, Cylinder, first. Make a constant for pi, as you'll need it for any containers that aren't square. For the members, use protected. Finally, add a public function to control the volume. V= pi * (r2) * h is the formula.arrow_forward
- shows the complete anagram.cpp program. use a class to represent theword to be anagrammed. Member functions of the class allow the word to be displayed, anagrammed, and rotated. The main() routine gets a word from the user, creates a word object with this word as an argument to the constructor, and calls the anagram() member function to anagram the word.arrow_forwardNovice: How can i access a main class objects from outside the function? / Better Alternative? If i have 4 Student objects how can i print the information for the specific object given one parameter about the class, like the students Idnumber. What i came up with was making a checkId void function that takes the user input and runs an if else chain checking if the Id belongs to student 1-4 then printing the details of that classes object with the void function print. ideally i would want the if-else chain in the checkId function to call the print( student1-4) class object but im not sure how to properly do that. i dont think this is the best way to go about it, if you have any recommendations or alternatives please help me out.arrow_forward1. Create a Student class that implements the Person interface. As well as storing the students name and email, also store their course grade (e.g A, B, C) in a member variable. The grade should be accessible via a getGrade method. For the implementation of getDescription return a message along the lines of “A C grade student”, substituting the students actual grade.2. Create a Lecturer class that implements the Person interface. This class should also store the subject that the lecturer teaches. Add a getSubject method, and implement getDescription so that it returns a suitable message, e.g. “Teaches Biology”.3. Create a third class, Employee that implements the interface. This should also store the name of the department the Employee works in (available via getDepartment). Again, getDescription should return a suitable message.arrow_forward
- A new class safe member that would allow us to export a reference to a member Suggest a simple scheme for creating a new class SafeMember that would allow us to export a reference to a Member. The classes outside the system should be unaware of this additional class, and access the reference like a reference to a Member object. However, the reference would not allow the integrity of the data to be compromised. Remember that when designing the “Return Book with fines” use case, Member object is returned to the UserInterface to be able to display the member information such as owed fine. But this also means that the UserInterface can access all the Member methods. Your implementation of SafeMember class should prevent this.arrow_forwardPlease see attached.arrow_forwardA C++ assignment Implement the GradedActivity class. Copying from the pdfs is fine. Create a new class Assignment which is derived from GradedActivity. It should have three private member ints for 3 different parts of an assignment score: functionality (max 50 points), efficiency (max 25 points), and style (max 25 points). Create member function set() in Assignment which takes three parameter ints and sets the member variables. It should also set its score member, which is inherited from GradedActivity, using the setScore() function, to functionality + efficiency + style. Signature: void Assignment::set(int, int, int) Create a main program which instantiates an Assignment, asks the user for its functionality, efficiency, and style scores, and prints out the score and letter grade for the assignment. ___________________________________________________ Examples from the pdfs: d PassFailExam::set(int q, int m, int p) { double numericScore, pointsEach; numQuestions =…arrow_forward
- Help of what these errors mean. In C# • Create a Class, named Student, to hold properties of Student Last Name, Student First Name, Student ID (9 digits), Course Prefix and Number, and the tests (Test 1, Test 2, Test 3, Test 4). Create appropriate setter and getter accessors, and constructors. Use access modifiers. Example: First Name : Pat Last Name : Smythe Student ID : ABC111333 Course Prefix : CIST Course Name : 2431 Test 1 : 100 Test 2 : 90 Test 3 : 80 Test 4 : 88 • Prompt the user for the Student Last and First Name, Student ID, Course Prefix and Number and the tests. • Include at least one exception handling function. • Use an array to store the 4 test grades. • Use a looping structure to populate the array. • Calculate the numeric average based upon the 4 equally-weighted numeric grades. • Display all the data for each of student using a looping structure. • Display the numeric average for each student. • Create a function that will convert the numeric average to a…arrow_forwardIn this Assignment you will use an abstract class to define, read, store, and print questions for a test. you will start by writing an abstract TestQuestion class that contains the following: • A protected String variable that holds the test question. • An abstract method protected abstract void readQuestion() to read the question. Now define two subclasses of TestQuestion, Essay and MultChoice which implement the abstract methods. Essay will need an instance variable to store the number of blank lines needed for the answering space. MultChoice will not need this variable, but it will need an array of Strings to hold the choices along with the main question. You will also need to write toString methods for the MultChoice and Essay classes that return nicely formatted versions of the questions. Now define a class WriteTest that creates an Arraylist of TestQuestion objects. Assume that the input as the following: 1. type of question (character, m3Dmultiple choice, e=essay). 2. number of…arrow_forward2. Implement the class below such that it should provide structure with necessary Data Members to all the sub-classes of itself. The object creation of this class is not mandatory. Book -name:String -author:Author -price:double -qty:int = 0arrow_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 Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning