【发布时间】:2021-07-05 05:16:25
【问题描述】:
#include<iostream>
using namespace std;
class complex{
private:
int x;
public:
friend void fun(void);
};
void fun(void)
{
cout<<"outside "<<endl;
}
int main()
{
complex c1;
c1.fun();
return 0;
}
为什么我收到以下错误,指出“类复合体”在 VS 代码中没有名为“fun”的成员
36_friend_function.cpp: In function 'int main()':
36_friend_function.cpp:19:8: error: 'class complex' has no member named 'fun'
c1.fun();
^~~
【问题讨论】:
-
请解释您的目标,而不仅仅是您遇到的症状
标签: c++ class friend-function