#include <iostream> #include <vector> #include <string> using namespace std; //struct X { // friend void f() {}//这里就没问题 //}; int main() { struct X { friend void f() {}//error C2689: “f”: 不能在局部类中定义友元函数 }; }
闭关修行中......
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?
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?