Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A) Assume the existence of a class named Window with functions named close and f

ID: 3552481 • Letter: A

Question

A) Assume the existence of a class  named Window with functions named close and freeResources, both of which accept no parameters and return no value . Write a destructor for the class that invokes close followed by freeResources.


B) Assume a class Window with accessor methods getWidth that accepts no parameters and return an integer . Assume further an array of 3 Window elements  named winarr, has been declared and initialized . Write a sequence of statements that prints out the width of the widest window in the array .

Explanation / Answer

A) Destructor

--------------------

Window::~Window()

{

    close();

    freeResources();

}


B) Code Snippet

------------------------------

int widest = 0;

for (int i = 0; i<3, i++){

cout<<"Width of "<<i+1<<" th element = <<winarr[i].getWidth()<<endl;

if(widest > winarr[i].getWidth())

      widest = winarr[i].getWidth();

cout<<"Widest window has width = " <<widest<<endl;

}


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote