在Visual C++(2008和2010)中,以下代码无法编译,并出现以下错误:
#include <memory>
void Foo( std::shared_ptr< int > test = ::std::make_shared< int >( 5 ) )
{
}
class P
{
void
Foo( std::shared_ptr< int > test = ::std::make_shared< int >( 5 ) )
{
}
};
Run Code Online (Sandbox Code Playgroud)
错误C2039:'make_shared':不是'`global namespace''的成员
错误C3861:'make_shared':找不到标识符
它抱怨P :: Foo()的定义不是:: Foo().
有人知道为什么Foo()有一个与std :: make_shared但不是P :: Foo()的默认参数有效吗?