我在我的代码中包含了两个库,它们都有名为" getch"的函数,两个函数都没有参数,都返回void。如何强制程序选择" getch"从图书馆A而不是B?
答案 0 :(得分:3)
你不能。
这就是namespace
被发明的原因,因此您可以使用封闭的namespace
限定其姓名。
//These modifications have to be made in the library source files
namespace A { void getch(); }
namespace B { void getch(); }
//When you want to use them
A::getch();
B::getch();