Calling a function overloaded in several namespaces from inside one namespace

前端 未结 3 552
广开言路
广开言路 2021-01-02 16:51

I have the following code snippet:

void foo(double a) {}

namespace bar_space
{
  struct Bar {};

  void foo(Bar a) {}
}

foo(double) is a g

3条回答
  •  自闭症患者
    2021-01-02 17:49

    However, in your sample code you could use something like that

    namespace bar_space 
    {
        using ::foo;
        void baz()
        {
           Bar bar;
           foo(5.0);
           foo(bar);
        }
    }
    

提交回复
热议问题