131.typename在嵌套类中的作用

 1 #include <iostream>
 2 using namespace std;
 3 
 4 class myit
 5 {
 6 public:
 7     static int num;
 8 
 9     class itit
10     {
11 
12     };
13 };
14 
15 int myit::num = 0;
16 
17 template <class T>
18 class my
19 {
20 public:
21     T * p;
22     T t;
23     //加上typename表示根据里面的类型创建一个指针
24     //如果不加上typename则会理解成*号
25     typename T::itit *x;
26 };
27 
28 void main()
29 {
30     my<int> my1;
31     cin.get();
32 }
原文地址:https://www.cnblogs.com/xiaochi/p/8650480.html