M
Mike Copeland
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
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