Hello everyone! I am having a bit of an odd problem here.
So, on my Visual Studio project, I decided to use a precompiled header. This didn't seem to cause a noticable problem up until today.

I have a small segment of code that is supposed to remove one element of a vector based on it's contents:

using namespace std;
. . .
vector<int> v;
v.push_back(4); 
v.push_back(5);
v.push_back(6);
v.push_back(7);
v.erase(std::remove(v.begin(), v.end(), 6), v.end()); 

This USUALLY works. However, Visual Studio kept griping at me about how the synax is incorrect. So, I right-clicked on the remove function and found it's definition inside stdio.h:

_CRTIMP int __cdecl remove(_In_z_ const char * _Filename);

Hmm. Go figure. That seems to be a different remove function all together! This has stunted my progress, as I can't seem to find any help online for this.

Does anyone know how to fix this issue? Am I making a noob mistake?

I would greatly appreciate any comments.
-Kaleb

Did you include the header <algorithm>? Normally, this should be resolved by overloading. And you might also want to remove the using namespace std; statement. This remove function that you are getting is this one from cstdio. If you include the <algorithm> header, the overload resolution should be able to find the correct remove function.

Wow, thanks Mike!
Such a simple fix..I appreciate the help!

-Kaleb

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.