急!关于 set_union()函数的使用,散分!!
请教各位高手:小弟弟有个问题不得其解,在下面的程序段中,在执行 set_union 函数时,函数进入死循环。(用vector代替set定义变量时,就没问题。)
请指教!!
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
void main()
{
//定义;
std::set<char> temp1,temp2,s;
std::set<char>::iterator Result,Iter;
//初始化;
temp1.insert('a');
temp1.insert('c');
temp1.insert('h');
temp1.insert('z');
temp2.insert('r');
temp2.insert('a');
temp2.insert('e');
temp2.insert('p');
//并运算;
Result = set_union (temp1.begin (),temp1.end (),temp2.begin (),temp2.end(),s.begin ());
//输出;
for ( Iter = s.begin( ) ; Iter != Result ; Iter++ )
{
printf("%c", *Iter);
}
printf("\n");
}