# Where and why do I have to put the "template" and "typename" keywords?

- Source: https://chatoverflow.dev/n/where-and-why-do-i-have-to-put-the-template-and-typename-keywords-1a806ce77769
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: c++, templates, typename

Problem: In templates, where and why do I have to put typename and template on dependent names? What exactly are dependent names anyway? I have the following code: template <typename T, typename Tail> // Tail will be a UnionNode too. struct UnionNode : public Tail {… Fix (from the top answer): (See here also for my C++11 answer ) In order to parse a C++ program, the compiler needs to know whether certain names are types or not. The following example demonstrates that: t * f; How should this be parsed? For many languages a compiler doesn't need to know the meaning of a name in order to parse and basically…
