c++ - 为什么不能在局部类中定义友元函数,而全局类就可以?
阿神
阿神 2017-04-17 12:05:57
0
2
572
#include <iostream>
#include <vector>
#include <string>
using namespace std;
//struct X {
//    friend void f() {}//这里就没问题
//};
int main()
{
    struct X {
        friend void f() {}//error C2689: “f”: 不能在局部类中定义友元函数
    };
}
阿神
阿神

闭关修行中......

reply all(2)
伊谢尔伦

C and C++ functions cannot define functions inside functions.

巴扎黑

The scope of local classes is already very limited. Do you think it is necessary to declare friends? Why is there such a need?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template