#include<iostream>
#include<string>
using namespace std;
class whw
{
private:
int Age;
friend void whbsb(const whw& wxk);
public:
whw(int InputAge)
{
Age=InputAge;
}
};
friend void whbsb(const whw& wxk)
{
cout<<"年龄="<<wxk.Age<<endl;
}
int main()
{
whw lsh(50);
return 0;
}
我在类中声明了一个友元函数,并且在类外进行了实现!但是编译没有通过,不知道是什么语言啊!
error C2255: 'whbsb' : a friend function can only be declared in a class
求指点,能解决问题的,一定采纳!
我也发现了,真实罪过啊!
本回答被提问者采纳