std::find

Started by
4 comments, last by Freaker13 20 years, 8 months ago
Hi all, When i use std::find, i get the error: error C2039: ''find'' : is not a member of ''std''. i''m using vs6.0. thx in advance
Advertisement
Shouldn''t you be using something like std::map::find or std::set::find?
find is a member function of these (and other) STL templates.
Blake's 7 RPG - a new project
I would guess that you are messing up with namespaces. Your code should look like one of these:
1. #include <algorithm> std::find(...);

2. #include <algorithm> using std::find; find(...);

3. #include <algorithm> using namespace std; find(...);


[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || MSVC++ Library Fixes || BarrysWorld || E-Mail Me ]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]
thx dudes
quote:Original post by Strewth
Shouldn't you be using something like std::map::find or std::set::find?
find is a member function of these (and other) STL templates.

Indeed, std::map has an overloaded find() public member function. Freaker13 , though, is talking about std::find(), which is one of the [search/non-mutating] generic algorithms (a set of independent functions). For example:
#include <vector>#include <algorithm>#include <string>#include <iostream> ... std::vector<std::string> V(..., ...); std::sort( V.begin(), V.end() );    // generic algorithm `sort' // (yes, could, and probably would, be put in if statement)std::vector<int>::iterator found = std::find( V.begin(), V.end(), "word" );  // generic algorithm `found'if ( found != V.end() )    std::cout << "found" << std::endl;else    std::cout << "not found" << std::endl; std::rotate( V.begin(), V.begin() + V.size() / 2, V.end() ); // generic algorithm `rotate' std::reverse( V.begin(), V.end() );   // generic algorithm `reverse' ... etc., etc.


[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || MSVC++ Library Fixes || BarrysWorld || E-Mail Me ]

[edited by - Lektrix on August 16, 2003 8:34:59 AM]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]
Learn something new every day, thanks
Blake's 7 RPG - a new project

This topic is closed to new replies.

Advertisement