M
Mike Copeland
I'm getting more and more confused about working with STL containers:
everything I try seems to produce a new compiler diagnostic. Here's the
latest (and simplest) thing I've tried to do:
struct TEST
{
int num;
int count;
string str;
bool operator==(const TEST &l, const TEST &r) const
{
return l.num == r.num;
}
} testWork;
The compiler produces "C:\CPP\source\list21.cpp(40) : error C2804:
binary 'operator ==' has too many parameters" -I am totally puzzled
about what this means...and why.
I am _trying_ to create a small structure to be used in an STL list
(e.g. list<TEST>) that I could sort and change values. The first step
(I thought) was to define an operator that would support "find", but I
can't get anything to compile.
I'd appreciate some guidance on how to get going on this task (the
"find", changing object elements, etc.). TIA
everything I try seems to produce a new compiler diagnostic. Here's the
latest (and simplest) thing I've tried to do:
struct TEST
{
int num;
int count;
string str;
bool operator==(const TEST &l, const TEST &r) const
{
return l.num == r.num;
}
} testWork;
The compiler produces "C:\CPP\source\list21.cpp(40) : error C2804:
binary 'operator ==' has too many parameters" -I am totally puzzled
about what this means...and why.
I am _trying_ to create a small structure to be used in an STL list
(e.g. list<TEST>) that I could sort and change values. The first step
(I thought) was to define an operator that would support "find", but I
can't get anything to compile.
I'd appreciate some guidance on how to get going on this task (the
"find", changing object elements, etc.). TIA