All challenges
Multiple ChoiceIntermediate 45s

Template instantiation in TUs

If a class template is instantiated in two TUs with the same arguments, the linker:
Options
  1. 1It reports a duplicate-symbol error for the class, since two instantiations cannot coexist.
  2. 2It creates two distinct runtime types that share a name but cannot interoperate at runtime.
  3. 3Folds the identical instantiations together (vague linkage / COMDAT); identical definitions are required, else ODR UB.
  4. 4It instantiates the template only in whichever translation unit happens to #include it first.

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle