Logo

Question preview

To <T> or not to <T>

What this preview is

About this preview

To <T> or not to <T> is a easy quant interview question on language knowledge in Cpp, asked at Google.

Unlock full access to getcracked

Join to unlock this question, detailed solutions, and our complete library of quant finance interview prep.

What this C++ template knowledge question tests

This is an easy question that probes practical understanding of C++ template syntax and instantiation rules. It's the kind of question Google and other companies ask to separate candidates who have actually written templated code from those who have only studied the theory.

The question presents two competing implementations of a templated Stack class and asks you to reason about which one will actually compile. This requires you to understand how the C++ compiler resolves template declarations, where the template keyword appears in nested or member contexts, and the subtle difference between what looks reasonable and what the standard permits. The key is recognizing the syntactic rules governing template member functions and class definitions, not the logic of the Stack itself.

  • Template syntax in class and function declarations
  • Scope resolution and the template keyword in dependent contexts
  • Compiler error messages in template instantiation