Can I write functors using a private nested struct?
Posted
by Kristo
on Stack Overflow
See other posts from Stack Overflow
or by Kristo
Published on 2010-03-22T15:29:04Z
Indexed on
2010/03/22
15:31 UTC
Read the original article
Hit count: 225
Given this class:
class C
{
private:
struct Foo
{
int key1, key2, value;
};
std::vector<Foo> fooList;
};
The idea here is that fooList
can be indexed by either key1
or key2
of the Foo struct. I'm trying to write functors to pass to std::find
so I can look up items in fooList
by each key. But I can't get them to compile because Foo
is private within the class (it's not part of C's interface). Is there a way to do this without exposing Foo
to the rest of the world?
(note: I've got to run to a meeting. I'll be able to post more sample code in about a half hour.)
© Stack Overflow or respective owner