请问下面这个变量m是什么类型?NOTIFICATION 是一个 struct
class EventSensor;
EventSensor<NOTIFICATION> m;
PHPz2017-04-17 15:38:14
如果EventSensor是一個類別模板(你給的聲明不是類別模板的聲明)。變數宣告EventSensor<NOTIFICATION> m;
會宣告一個以NOTIFICATION為模板參數特化出的類別的實例m,這個類別稱為"EventSensor
也就是說,變數m的型別就是EventSensor<NOTIFICATION>
。
引自cppreference, templateWhen template arguments are provided or, for function and class (since C++17) templates only, deduced, they are substituted for the template parameters to temptain a specialization of the template, that; a specific type or a specific function lvalue.
ringa_lee2017-04-17 15:38:14
是的,
伊谢尔伦2017-04-17 15:38:14
m 類型為 EventSensor
如
ArrayList<String> mStrList = new ArrayList<String>();
mStrList.add("string1");
mStrList.add("string2");
String s = mStrList.get(1);
mStrList 的型別為ArrayList
裡面的元素s=mStrList.get(1);的型別為String;