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
Language: C++ Create a class called publication that stores the title (char array) and price (float) of a publication. From this class derive two classes: book, which adds a page count (int) and tape, which adds a playing time in minutes (float). Each of the three classes should have a getdata() function to get its data from the user using input from the keyboard and a putdata() function to display the data.Write a main function that creates an array of pointers to publication. In a loop, ask the user for data about a particular type of book or tape to hold data. Put the pointer to the object in the array. When the user has finished entering data for all the books and tapes, display the resulting data for all the books and tapes entered, using a for loop and a single statement such as: pubarr[j] -> putdata(); To display the data from each object in the array.
The following describes the difference between void and NULL pointers: Make proper use of examples to bolster your argument.
Program language: C++ A publishing company markets both hardcopy and eBook versions of its work. Create a class publication that stores the title and price of a publication. From this class derive two classes: book, which adds a page count, and digital, which adds a storage capacity in MG bytes. Each of these classes should have a getdata() function to get its data from the user at the keyboard and put a putdata() function to display its data. Add a base class sales that hold an array of three floats so that it can record the dollar sales of a particular publication for the last three months. Include a getData() function to get three sales amounts from the user and a putdata() function to display the sales figures. Modify the book and digital classes so they are derived from both publication and sales. An object of the class book or digital should input and output sales data along with its other data. Write the main function to create a book object and a digital object and test their…
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