0

我想知道,如何将未命名命名空间的 const 成员变量设置为默认函数参数,其中函数在命名命名空间中声明。好吧,我想这对我来说很难解释,这是我想做的一个例子:

//foo.h
namespace foo
{
    void justAFunction(std::string function_string = unnamed_str);
}

//foo.cpp
#include "foo.h"

namespace foo
{
    namespace
    {
        const std::string unnamed_str = "simple string";
    } 

    void justAFunction(std::string function_string)
    {
        ...
    }
}

这不联系...

我仍然可以在函数定义中编写默认参数,但这不是我想要的,因为调用者不会看到它,对吧?任何建议如何正确编码?

4

0 回答 0