About this question
Medium · Code Analysis · Quant Trader interview question · C++, nullptr, dereference, segfault, undefined-behavior
You are developing a high-frequency trading system in C++. A function findBestOrder(orderBook) searches an order book for the optimal order to execute. If no suitable order is found, findBestOrder returns nullptr. The calling code then attempts to access the price member of the returned order object without checking for nullptr. Specifically: What is the most likely outcome when findBestOrder returns nullptr and the calling code attempts to dereference it to access bestOrder->price?