Ask Question
7 March, 05:35

Define the following Window class:

a. integer data members, width and height

b. a constructor that accepts two integer parameters (width followed by height) and uses them to initialize the data members

c. a friend function, areSameSize, that accepts two Window objects and returns a boolean indicating if they are the same size.

d. Two windows are the same size if the widths and heights match.

+5
Answers (1)
  1. 7 March, 08:50
    0
    The following Window class are given below:

    class Window / / define a class Window

    {

    private: / /access modifier

    int width, height; / / integer type variable which is width and height

    public: / /access modifier

    Window (int w, int h) / /constructor that accepts two integer parameters

    {

    width = w;

    height = h;

    }

    friend bool areSameSize (Window a, Window b)

    {

    if ((a. height = = b. height) && (a. width = = b. width))

    return true;

    else return false;

    }

    };

    Explanation:

    According to the question: Firstly we have define a class which name is 'Window' and then we take two integer type data member and after that we have constructor that takes two integer type parameters and after all we have a areSameSize, friend function, which can take two objects and then it give output in the form of true or false, if they are the equal size and finally we check that if the width and the height match then it returns the true and else it returns the false
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Define the following Window class: a. integer data members, width and height b. a constructor that accepts two integer parameters (width ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers