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

g shows the overloading of constructors for the Rectangle class. What is the exa

ID: 3767849 • Letter: G

Question

g shows the overloading of constructors for the Rectangle class. What is the exact output of the 5. The following shows the overloading of constructors for the R (10 #include class Rectangle int height; int width; public: Rectangle0 //constructor with no argument height 0; width = 0; Rectangle (int h, int w) liconstructor with two arguments height = h; width = w; Rectangle (int h) I/constructor with one argument height h; width = h; void getEdges cout>height coutscende Enter the Width of the rectangle:" cin>width;

Explanation / Answer

output of the above program

The edges are initialized as

//Initially default constructer will be called ,so the value of height and width of the rectangle will be set //to zero

Height of the rectangle:0

Width of the rectangle:0

Get new values of the edges

//when we call getValues function we have to enter height and width of rectangle.In this case I entered //10 and 5

enter the height of rectangle:10

enter the width of rectangle:5

//when I call showValues function,the value entered by me will be printed as height and width of a //rectangle.

Height of the rectangle:10

width of the rectangle:5

Second case

//now parameterised constructed will assign the value of height and width as 11 and 17 as it is passed as //parameter

The edges are initialized with 2 parameters

Height of the rectangle:11

width of the rectangle:17

Third case

//here height and width will become 10.It is not printed because we have not called the showValue //function after assigning the values

The edges are initialised with a single parameter

2.

private class members - These members can only be accessed within the class that defines them.

protected class members- These members are accessible in the class that defines them and in other classes which inherit from that class.Not member function cannot handle protected class members.

3.

In order to understand exceptional handling,frst we have to understand the meaning of exceptions.

Exceptions are the special cases which come when we execute the program.The way we handle them is called as exceptional handling.If exceptions are not handled,then the program will crash during runtime.

Example:

1.divide a number by zero:when we divide a number by zero,the program must be able to handle this case,because we all know that dividing a number by zero is not a valid case.

2.argument out of range:when values are very big or when there is no enough memory,program should be able to handle this case.