Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > list find_if us...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 45869 of 47925
Post > Topic >>

list find_if usage

by mrc2323@[EMAIL PROTECTED] (Mike Copeland) May 11, 2008 at 09:33 PM

I am trying to learn and use STL lists, and I'm getting a compile 
error with initial declarations.  Here;s the code I have so far:
struct GENCHECK                                 // Gender Check data
{
	char   genCode;
	string firstName;
} gWork;
typedef list<GENCHECK> NAMES;
        NAMES	 genData;
        list<GENCHECK>::iterator gIter;

class nameEqual : public unary_function<NAMES, bool>
{      // predicate class to perform structure element comparison
	string s;
public:
	explicit nameEqual (const string &ss) : s(ss) {}
	bool operator() (const NAMES &e) const { return e.firstName == s; 
}
};

   The compiler error (MS VS6.0) is:

error C2039: 'firstName' : is not a member of 'list<struct 
GENCHECK,class std::allocator<struct GENCHECK> >'

on the "bool operator" line in the class definition.

   I constructed this code from examples I found in various places, but 
nothing I found does quite what I'm trying here.  Basically, I'm trying 
to build a routing that populates this <list> structure, then searches 
for matches (or mismatches) on list via the string element of the 
object.  What am I doing wrong here?
   If there is another STL type I should be using for this application, 
or if I should use another "search" technique, please suggest that, as 
well.  TIA
 




 4 Posts in Topic:
list find_if usage
mrc2323@[EMAIL PROTECTED]  2008-05-11 21:33:15 
Re: list find_if usage
mrc2323@[EMAIL PROTECTED]  2008-05-11 22:01:37 
Re: list find_if usage
Oleg Gaier <g_for_usen  2008-05-12 10:52:49 
Re: list find_if usage
Vulcan <vulcan.eager@[  2008-05-12 02:48:33 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 6 17:35:36 CDT 2008.