containers/member-types/mem-types-2.cpp - Same program - now with use of typename as prefix of 'nested dependent type names'. | Lecture 6 - slide 13 : 40 Program 2 |
// Using typename to emphasize that a dependent name (a name that depends on a template parameter) is a type name. #include <iostream> #include <string> #include <list> int main(){ using namespace std; list<char> lc; lc.push_back('a'); lc.push_back('b'); lc.push_back('e'); typename list<char>::value_type x = 'c'; // A complicated way to denote the type char typename list<char>::iterator lc_it = lc.begin(); // The iterator type of list<char> typename list<char>::size_type sz = lc.size(); // The size type of list<char> }