Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我有一个base带有构造函数的类,它采用(T V). 我继承obj了具有构造函数的类,()我想创建类似的东西
base
(T V)
obj
()
base * new_list_item = new obj()
但是如何T val;在 C++ 中传递给 obj 基本构造函数值呢?
T val;
使用初始化列表:
class obj : public base { public: obj(T v) : base(v) {} };