Typename Changes

Typename Changes - Typename Changes Jonathan Schilling,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Typename Changes Jonathan Schilling, jls@sco.com This newsletter has not previously mentioned the "typename" keyword. This language feature was introduced several years ago during the standardization process. To understand its purpose, consider the following code: template<class T> class Y { T::A a; // error }; When the compiler sees this class template definition, it has no way of knowing what T::A represents. In particular, it doesn't know whether T::A is a type or is something else. Usages such as T::A(bb); might either be a function call of T::A passing global variable bb as an argument, or a declaration of a variable bb of type T::A. (Yes, in C and C++ you can declare variables that way; makes parsing lots of fun!) Issue #017 of the Newsletter discussed the idea of dependent and non-dependent names within templates. T::A is a dependent name (because part of the name is the template formal parameter T), and the language rule became that a dependent name
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

Typename Changes - Typename Changes Jonathan Schilling,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online