【发布时间】:2012-10-01 15:25:02
【问题描述】:
class TestGet : public ::testing::Test
{
protected:
TestGet()
: _txHandle(11)
{
_interface.get = mockGet;
}
Interface_T _interface;
Handle_T _txHandle;
DB _db;
};
如果我更改 DB 使其只有以下构造函数:
explicit DB(Interface_T& _interface):
_interface(interface)
{
}
我现在是否需要在我的TestGet 类中使用std::shared_ptr 声明_db,并在构造函数中使用_interface 对其进行初始化?
更新:
问题是我有:
private:
Interface_T _interface;
在 DB 类中而不是在引用中。
【问题讨论】:
-
你的问题有点含糊。究竟是什么问题?在 _txHandle(11) 之后添加 , DB(_interface) 会起作用吗?
标签: c++ class constructor initialization