类模板的定义与实例化 — 计算机选择题
题目
某程序需要定义类模板 Cabinet,使其数据成员 item 的类型由模板参数决定,并声明一个 item 类型为 unsigned long 的对象。以下哪段代码同时满足要求?
A. template<class T> class Cabinet { T item; }; Cabinet<unsigned long> c;
B. template<class T> class Cabinet { T item; }; Cabinet c<unsigned long>;
C. class Cabinet<T> { T item; }; Cabinet<unsigned long> c;
D. template<class T> class Cabinet { unsigned long item; }; Cabinet<int> c;