EBK C HOW TO PROGRAM
EBK C HOW TO PROGRAM
8th Edition
ISBN: 9780133964639
Author: Deitel
Publisher: PEARSON CUSTOM PUB.(CONSIGNMENT)
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.
3- It is not possible to change the value of the pointer. (True or False). 4- If the following lines of code have errors, correct them; otherwise, write "no errors." for (int i=2; i<5; i++) { int s=1*2; } cout << s; 5- A function cannot be called from inside another function. (True or False). 6- How to make a function return multiple values? 7- Every class member is by default. (public, private, not public nor private) 8- Create an instance of the following class and call its methods. class Exam{ int grade; public: void seta (int b) (grade=b; } int geta () {return grade; } 9- When the word const is put before the variable definition, what does that mean? 10- How to concatenate two strings in C++ language? C++
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