Assume the existence of a Window class with integer data members width and heigh
ID: 3773672 • Letter: A
Question
Assume the existence of a Window class with integer data members width and height. Overload the << operator for the Windowclass -- i.e., write a nonmember ostream-returning function that accepts a reference to an ostream object and a constant reference to a Window object and sends the following to the ostream: 'a (width x height) window' (without the quotes and with width and height replaced by the actual width and height of the window. Thus for example, if the window had width=80 and height=20, << would send 'a (80 x 20) window' to the ostream.) Don't forget to have the function return the proper value as well. Assume the operator has beendeclared a friend in the Window class
Explanation / Answer
class windowBorderClass : public Window
{
private:
int borderWidth;
public:
//constructor
windowBorderClass(int border) : Window ()
{
borderWidth = border;
}
int getBorderWidth();
};
//method to get borderclass width
int windowBorderClass::getBorderWidth()
{
return (Window::getWidth() - borderWidth);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.