← 返回 jpmorgan 的题目列表C++ Virtual / Destructor / Pointer Review
类型:qbank
Quant finance onsite includes C++ code-reading and language-semantics questions around virtual functions, destructors, dangling pointers, and pointer-vs-reference differences.
Requirements
Read C++ snippets and predict output or behavior.
Explain virtual function dispatch.
Explain destructor behavior and dangling-pointer risks.
Compare pointer vs reference semantics in C++.
Notes
For virtual functions, be explicit about static type, dynamic type, and whether the function is declared virtual in the base class.
For destructors, discuss ownership, lifetime, deleting through a base pointer, and why virtual destructors matter for polymorphic bases.
Pointer vs reference answers should cover nullability, reseating, syntax, lifetime assumptions, and when each is appropriate.
Preparation
Write small snippets for base/derived virtual dispatch and predict output before compiling.
Review Rule of Three/Five basics, RAII, smart pointers, and undefined behavior from dangling pointers.
Practice explaining references as aliases with stricter binding rules, not as safer pointers in every context.