0
或者我需要將std::make_unique
轉換成任何形式?如何投射std :: make_unique,以便我可以使用類中聲明的函數?
我有一些功能的Foo類,我可以使用:
FOO::FOO(const yoo &yoo, float numbers) :
num_to_execute(numbers)
{
...
...
}
void FOO::execute()
{
execute(num_to_execute);
}
在另一個的.cpp,我給出的代碼initated FOO使用下面的方法:
new_foo = std::make_unique<FOO>(yoo, number);
(到現在爲止一切都是正確的)。我想要做的是在我的new_foo上調用execute。我試着用
new_foo.execute();
但它說:
error: 'class std::unique_ptr<WORK::TOBEDONE::FOO>' has no member named 'EXECUTE'
execute
應該能夠呼籲各<WORK::TOBEDONE::FOO>
但標準::的unique_ptr是給我很難明白我應該做的。