C++-具有相同名称的函数

C++ - Functions with the same name

本文关键字:函数 C++-      更新时间:2023-10-16

我必须包含两个不同的头文件(一个是标准的assert.h),它们都有一个assert函数。我无法控制这些头文件(所以我无法更改它们)。我收到一个编译器错误,说明这两个函数之间的冲突。如何在代码中指定应该使用assert.h中的assert函数来消除此编译器错误?

namespace OtherAssert
{
#include "private_assert.h"
}
//...
void foo()
{
    OtherAssert::assert(true); // non-standard assert
    assert(true); // the one from standard assert.h
}