我编写了下面的代码来使用set_intersection命令: 它编译并在main()内运行良好,但是当我尝试在类中的函数内运行它时,我得到以下错误:
Error 6 error C2064: term does not evaluate to a function taking 5 arguments
8 IntelliSense: call of an object of a class type without appropriate operator() or conversion functions to pointer-to-function type
请帮我理解是什么问题,谢谢
#include "stdafx.h"
#include <cassert>
#include <iostream>
#include <set>
#include <string>
int ra[] = { 12, 2, 3, 4, 8, 10, 1 };
int rb[] = { 1, 3, 6, 9, 12, 17 };
set<int> a(ra, ra + sizeof(ra) / sizeof(int));
auto result_1 = a.insert(17);
set<int> b(rb, rb + sizeof(rb) / sizeof(int));
set<int> c;
set_intersection(a.begin(), a.end(),
b.begin(), b.end(),
std::insert_iterator< std::set<int> >(c, c.begin()));
答案 0 :(得分:0)
您可以使用std::inserter
set_intersection(a.begin(), a.end(), b.begin(), b.end(), std::inserter(c, c.begin()));