【发布时间】:2019-07-01 09:21:12
【问题描述】:
我有一个模板类“Foo”和另一个非模板类“Bar”。 我想在 Foo 中拥有 Bar 的实例,并公开 Bar 的一个仅对 Foo 私有的函数。
例子:
template <typename T>
class Foo
{
std::shared_ptr<Bar> m_bar;
bool Func()
{
return m_bar->DoSomething();
}
}
class Bar
{
private:
bool DoSomething();
}
【问题讨论】:
-
欢迎来到 Stack Overflow!
-
您可以阅读this page了解更多信息。
标签: c++ templates dependency-injection