🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

C2064 error

Started by
4 comments, last by pbivens67 2 years, 10 months ago

I am getting a Severity Code Description Project File Line Suppression State

Error C2064 term does not evaluate to a function taking 2 arguments CH2 c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\algorithm 2117

here is my code

#include <iostream>
#include<algorithm>
#include <vector>

int comparison = 0;

using namespace std;

bool same_set(vector<int>, vector<int>);

 int main()
{
	 int num_one, num_two, exit = 0;
	 vector<int> num_a;
	 vector<int> num_b;
	 while (exit != -1)
	 {
		 cout << "Enter first vector element: ";
		 cin >> num_one;
		 cout << endl;

		 cout << "Enter second vector element: ";
		 cin >> num_two;
		 cout << endl;

		 num_a.push_back(num_one);
		 num_b.push_back(num_two);

		 cout << "Enter exit(-1): ";
		 cin >> exit;
		 cout << endl;
		 
		 if (same_set(num_a, num_b) == 1)
		 {
			 cout << "Same Elements" << endl;
		 }
		 if (same_set(num_a, num_b) == 0)
		 {
			 cout << "Different Elements" << endl;
		 }
	 }

	 return 0;
}
 
 bool same_set(vector<int> a, vector<int> b)
 {
	 sort(a.begin(), a.end());
	 sort(b.begin(), b.end());
	 unique(a.begin(), a.end(), comparison);
	 unique(b.begin(), b.end(), comparison);

	 if (a.size() == b.size()) {
		 cout << "a" << endl;
		 for (vector<int>::size_type i = 0; i != a.size(); i++) {
			 /* std::cout << someVector[i]; ... */
			 if (a[i] != b[i]) {
				 return false;
			 }
		 }
		 return true;
	 }
	 return false;
 }
Advertisement

pbivens67 said:
unique(a.begin(), a.end(), comparison);

Comparison must be a function taking two integers and returning a boolean.

If you just want ‘==’, you don't need the comparison argument.

well I am passing in two vectors, is this correct?

Why are you using functions that you don't understand?

well I took out the comparison variable and it works

This topic is closed to new replies.

Advertisement