编译器错误 C3771
“标识符”: 在最近的命名空间范围内无法找到友元声明
无法在当前命名空间中找到指定模板的类模板声明 标识符 。
更正此错误
- 确保在当前命名空间中定义了模板标识符的类模板声明,或模板标识符是完全限定的名称。
示例
下列代码示例在 NA
命名空间中声明一个类模板和函数,但试图在 NB
命名空间中声明友元函数模板。
// C3771.cpp
// compile with: /c
namespace NA {
template<class T> class A {
void aFunction(T t) {};
};
}
// using namespace NA;
namespace NB {
class X {
template<class T> friend void A<T>::aFunction(T); // C3771
// try the following line instead
// template<class T> friend void NA::A<T>::aFunction(T);
// or try "using namespace NA;" instead.
};
}
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈