Starting from:
$30

$24

Assignment 2 Solution

The parameter in the Pop method is pass by reference because in pass by reference local parameters are references to the storage locations of the original arguments passed in. Changes to these variables in the function will affect the originals. So, as pop method will remove an element from the stack that’s why pass by reference is used.



2)No, we cannot change the size of an array without compiling because if we don’t compile it then the new instruction will not be processed.




The idea of const functions is not to allow the function to modify the object on which they are called. Therefore, Empty, IsFull, and Print methods has const because they are not supposed to change the stack.



4)There will surely be a difference as both are increment in a different way.




++top - increments the value of variable x after processing the current statement.



top++ increments the value of variable x before processing the current statement.

More products