Express the definition of the class rectangletype

Assignment Help C/C++ Programming
Reference no: EM13339836

The definition of the class rectangleType and the definitions of the operator functions are:
#include <iostream>
using namespace std;
class rectangleType
{
//Overload the stream insertion and extraction operators
friend ostream& operator<< (ostream&, const rectangleType &);
friend istream& operator>> (istream&, rectangleType &);
public:
void setDimension(double l, double w);
double getLength() const;
double getWidth() const;
double area() const;
double perimeter() const;
void print() const;
rectangleType operator+(const rectangleType&) const;
//Overload the operator +
rectangleType operator*(const rectangleType&) const;
//Overload the operator *
bool operator==(const rectangleType&) const;
//Overload the operator ==
bool operator!=(const rectangleType&) const;
//Overload the operator !=
rectangleType();
rectangleType(double l, double w);
private:
double length;
double width;
};
Notice that we have removed the member function print because we are overloading the stream insertion operator <<.
//The definitions of the functions operator+, operator*,
//operator==, and operator!= are the same as in Example 14-5.
ostream& operator<< (ostream& osObject,
const rectangleType& rectangle)
{
osObject << "Length = " << rectangle.length
<< "; Width = " << rectangle.width;
return osObject;
}
istream& operator>> (istream& isObject,
rectangleType& rectangle)
{
isObject >> rectangle.length >> rectangle.width;
return isObject;
}
Consider the following program. (We assume that the definition of the class rectangleType is in the header file rectangleType.h.)
//This program shows how to use the modified class rectangleType.
#include <iostream>
#include "rectangleType.h"
using namespace std;
int main()
{
rectangleType myRectangle(23, 45); //Line 1
rectangleType yourRectangle; //Line 2
cout << "Line 3: myRectangle: " << myRectangle
<< endl; //Line 3
cout << "Line 4: Enter the length and width "
<<"of a rectangle: "; //Line 4
cin >> yourRectangle; //Line 5
cout << endl; //Line 6
cout << "Line 7: yourRectangle: "
<< yourRectangle << endl; //Line 7
cout << "Line 8: myRectangle + yourRectangle: "
<< myRectangle + yourRectangle << endl; //Line 8
cout << "Line 9: myRectangle * yourRectangle: "
<< myRectangle * yourRectangle << endl; //Line 9
return 0;
}

Reference no: EM13339836

Questions Cloud

How far is the screen from the slit : Light of wavelength 580 nm passes through a slit of width 0.210 mm. How far is the screen from the slit
What is the type of block of the abbreviated ipv6 address : Given the following IPv6 addresses in hexadecimal colon notation, answer the following questions. Where applicable leave your answers in fully expanded hexadecimal colon notation.
Determine the volume of bodily fluid lost per hour : A 60.0-kg runner expends 335 W of power while running a marathon. determine the volume of bodily fluid (assume it is water) lost per hour
What could happen to the u.s. labor markets if immigration : Immigration is a major topic of concern in today’s economy. What are the possible problems and solutions for these concerns and what could happen to the U.S. labor markets if immigration is not controlled?
Express the definition of the class rectangletype : The definition of the class rectangleType and the definitions of the operator functions are.
What is the frequency of this wave : The displacement of a wave traveling in the positive x-direction is D(x,t)=(3.5cm)sin(2.7x?122t), where xis in m and t is in s. What is the frequency of this wave
What happens to price and output in the cournot : What happens to price and output in the Cournot, Bertrand and Stackelberg models if marginal costs increase by 10 percent if N=2, there are constant marginal costs (c), and firms face demand p = a - bq?
Calculate the fundamental frequency of vibration : A string with a mass of 6.00 g and a length of 7.00 m has one end attached to a wall; the other end is draped over a pulley, what is the fundamental frequency of vibration
How will the unemployment rate change as a result : How will the unemployment rate change as a result? How will the growth in GDP change as a result?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create class integerset

Create class IntegerSet for which each object can hold integers in the range 0 through 100. Represent the set internally as a vector of bool values. Element a[i] is true if integer i is in the set. Element a[j] is false if integer j is not in the set..

  Output the even numbers from 1 to 10 in ascending order

Output the even numbers from 1 to 10 in ascending order, then the odd numbers from 10 to 1 in descending order: 2 4 6 8 10 9 7 5 3 1. in C++

  Write a switch-case programming for calculation

How to use C++ to write a switch-case programming for calculation? Test the program for a wide range of possible inputs including division by zero and square root of negative values.

  Difference between a constant pointer

Explain the difference between a constant pointer to non-constant data and a non-constant pointer to constant data. Show the syntax to declare them.

  Users to input two forces by their components

write a programm to ask users to input two forces by their components of (Fx1,Fy1) and (Fx2,Fy2) from the keyboard.call twice the function to display both magnitude and direction angle of two forces on the screen.add two forces and display both magni..

  Problem on c++ tools

When working in teams (at most two students per team), send one solution file per team.

  Base process which communicate with child processes

Write a program which has a "base process" which communicates with child processes acting as "bombers" that it creates.

  Draw the heap

Eric Rowe Starting with an empty minheap, draw the heap after each the completion of the following operations  and repeat for a maxheap (replace removeMin() with removeMax()). Upload your drawings here. Hand drawn is fine:

  The main function should prompt the user

The main function should prompt the user for the 2 numbers, call the function to display the correct label, then calculate and display the sum of the numbers. Call the function to display the correct label, then calculate and display the differenc..

  Consists of an employee''s last name

Each input line consists of an employee's last name, first name, current base salary, total sales and percent commission. For example, in the first input line, the last name of the employee is Thomas, the first name is Andrew, the current base salary..

  C program to mips program

Convert the following C program to MIPS program. Assuming that i, j, k, f, are stored in registers $s0, $s1, $s2, $s3 already. The base address of arrays A and B are in registers $s4 and $s5, respectively. (30

  You should use pure recursive calls

You should use pure recursive calls completely and count the number of calls the program makes. You should count how many times recursive calls were made.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd