为什么这个程序错误
#include<iostream>
using namespace std;
class Set
{
public:
void Clearset();
friend void Intersection( const Set& , Set& );
private:
int size;
};
void Set::Clearset()
{
cout<<"12345";
}
void Intersection( const Set& set1, Set& set2)
{
set1.Clearset();//error
}
int main()
{
return 0;
}
[解决办法]
#include<iostream>using namespace std;class Set{public:void Clearset();[color=#FF0000]friend void Intersection( Set& , Set& ); [/color]private:int size;};void Set::Clearset(){ cout<<"12345";} [color=#FF0000]void Intersection( Set& set1, Set& set2)[/color]{ set1.Clearset();//error}int main(){ return 0;}