如何使用两个同名但命名空间不同的函数?

How to use two functions with the same name but different namespaces?

提问人:Tobias 提问时间:3/11/2021 更新时间:3/11/2021 访问量:116

问:

我的代码示例wirtten for Linux中存在以下问题:

例子.h

namespace abc
{
   int open();
}

example.cc

#include <sys/ioctl.h>
#include "example.h"
int abc::open()
{
   int a = open("abc", 123);
}

我打算在 ioctl.h 的上下文中使用 open(“abc”, 123),但该函数按照我的命名空间 abc 中的定义使用。

如何编写程序以使用正确的 open() 函数?

感谢您的帮助。

托比亚斯

C++ Linux 函数 命名空间

评论

1赞 Devolus 3/11/2021
用途 由于这两个函数具有不同的签名,因此编译器可能能够自行推断它。还是出现错误?::open(....)
1赞 Tobias 3/11/2021
干杯,这解决了我的问题!

答: 暂无答案