首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

为什么这个程序异常

2012-03-25 
为什么这个程序错误#includeiostreamusing namespace stdclass Set{public:void Clearset()friend voi

为什么这个程序错误
#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;
}

[解决办法]

C/C++ code
#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;} 

热点排行