class A {
};
class B {
using C = A;
// Compilation error:
// Type alias 'C' cannot be referenced with a class specifier
friend class C;
};
为什么类型别名在C++中不允许作为友元类名?
背后的原理是什么?
为什么类型别名在 C++ 中不允许作为友元类名?
您认为不允许类型别名成为友元的假设是错误的。正确的语法是
friend C
而不是 friend class C;
。