C How to Program (8th Edition)
C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
Question
Book Icon
Chapter 21, Problem 21.15E

a.

Program Plan Intro

Program Plan:

  • Declare variable xCoordinate and yCoordinate of type int as private member of class.
  • Provide declaration of ostream and istream operator as friend function.

Program Description: To create point class having two integer data membersxcoordinate and ycoordinate and provide declaration for stream insertion and stream extraction overloaded operator functions.

b.

Program Plan Intro

Program Plan:

  • Define overloaded insertion operator <<. Inside the definition use an if-else statement to check if the failbit was set or not.
  • If not then display the value of xCoordinate and yCoordinate data members of point class else display the message that wrong input was entered.
  • Also inside the else part use call clear function of clear the failbit.
  • Define overloaded extraction operator>>. Inside the definition use ignore function to ignore the first bracket, then read the first interger value , then again use ignore to ignore the comma and extra space, next read the ycoordinatevalue and finally use ignore to skip the last closing bracket.

Program Description: To implement the overloaded insertion and extraction functions of class point in file point.cpp.

c.

Program Plan Intro

Program Plan:

  • Include header file point.h
  • Declare a variable A of type Point.
  • Use cin statement to read the value of point in variable A.
  • Use cout statement to display the value of variable A if correct value was entered.

Program Description: To write a driver program to test the Point class.

Blurred answer
Students have asked these similar questions
state the statement either true or false.
X Whether the following statement is TRUE or FALSE? When an object is returned by a function, a temporary object is automatically created to hold the return value.
Indicate whether the following is true or false:Only pointers and references are permissible for use with dynamically bound virtual functions.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning