In the whilestatement of the method getNodeBefore, how important is theorder of the two boolean expressions that the operator &&joins? Explain.

What will be an ideal response?


The order of the boolean expressions is important. If the given entry—anEntry—is larger than any of the current entries in the sorted list, curPtr will become nullptrafter it is compared to the list’s last entry. The while statement will then evaluate the expression(curPtr!=nullptr)&&(anEntry>curPtr->getItem()). Because curPtr is nullptr, curPtr!= nullptr will be false and curPtr->getItem() will not execute due to short-circuit evaluation. If the boolean expression had been (anEntry>curPtr->getItem())&&(curPtr!=nullptr),curPtr->getItem() would execute and since curPtr is nullptr, an exception would occur.

Computer Science & Information Technology

You might also like to view...

Internet footprinting is a technical method of reconnaissance, which interests budding hackers and network security specialists alike.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Which of the following statements about running a macro is TRUE?

A) A macro can be run from the NewMacros dialog box. B) Running a macro is faster than manually choosing each command. C) A macro can be run from the Review tab. D) Running a macro is the same as recording a macro.

Computer Science & Information Technology

Validation rules place restrictions on the types of ________ that can be entered into cells

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

In the figure above, the number 2 refers to the _____ button.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology