C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 13, Problem 13.16E
(Complex Class) Write a
- Create a user-defined class Complex that contains the private integer data member'' real and imaginary and declares stream insertion and stream extraction overloaded operator functions as friends of the class.
- Define the stream insertion and stream extraction operator functions. The stream extraction operator function should determine whether the data entered is valid, and, if not, it should set fail bit to indicate improper input. The input should be of the form 3 + 81
- The values can be negative or positive, and it’s possible that one of the two values is not provided, in which case the appropriate data member should be set to 0. The stream insertion operator should not be able to display the point if an input error occurred. For negative imaginary values, a minus sign should be printed rather than a plus sign.
- Write a main function chat tests input and output of user-defined class Complex, using the overloaded stream extraction and stream insertion operators.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Indicate whether the following is true or false:Only pointers and references are permissible for use with dynamically bound virtual functions.
1. Inspect the code and in your own interpretation, describe the reason call to functionChangeIt_1(n) will not change x in main()?
2. Inspect the code and in your own interpretation, describe the reason parameter n inChangeIt_2(int *n) is a pointer, and statement in the function is *n = 6 ?
3. Write a function called void swap with two parameters, which will receive the addressof x and y as pointer. The function should swap the value of x and y only if x is larger thany. Print the value of x and y after the function call.
4. Write a function called double getAverage(int *array, int SIZE), whereit accept the array as pointer, and return the average of the array. Print the returnedvalue from this function. Always use *array rather than subscript to access the arrayvalue.
The distinction between void and NULL pointers is as follows: Make use of appropriate examples to support your response.
Chapter 13 Solutions
C++ How to Program (10th Edition)
Ch. 13 - (Write C ++ statements) Write a statement for each...Ch. 13 - (Inputting Decimal, Octal and Hexadecimal Values)...Ch. 13 - Prob. 13.8ECh. 13 - (Printing with field Widths) Write a program to...Ch. 13 - (Rounding) Write a program that prints the value...Ch. 13 - (Length of a String) Write a program that inputs a...Ch. 13 - (Converting Fahrenheit to Celsius) Write a program...Ch. 13 - In some programming language, string are entered...Ch. 13 - Prob. 13.14ECh. 13 - Prob. 13.15E
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
- Indicate whether or not the following is true:When it comes to dynamically bound virtual functions, only pointers and references are acceptable.arrow_forwardI need the answer quickly What is the meaning of the following declaration? int(*p[5])(); a) p is pointer to functionb) p is array of pointer to functionc) p is pointer to such function which return type is the arrayd) p is pointer to array of functionarrow_forwardIs that right?For functions that are flexibly bound, you need pointers or references.arrow_forward
- 7. using c++, Write a void function that accepts an integer array a and a integer SizeA, and an integer n, and adds n to every element in that array. Be sure to develop an appropriate name for your function.arrow_forwardTest on Functionsarrow_forwardDerive the run time of the following codearrow_forward
- When should you prefer the use of inline function over not inline function? Explain friend function and the situation in which you should use this concept? Explain with example program.arrow_forwardc++, anyone able to help with this, no vectors, no sstream, no pointers, also need a toLower function loop within to account for case insensivity, NEED ASAP pleasearrow_forwardPlease fill in the blanks for the following statements: The class function with no return type that is used to initialize data members is called the __________________________.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author: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
functions in c programming | categories of function |; Author: Education 4U;https://www.youtube.com/watch?v=puIK6kHcuqA;License: Standard YouTube License, CC-BY