Hi,
I'm trying to iterate over a container class. The class actually
contains a std::map, so I thought all I'd have to implement begin() and
end().
The example code has a problem in begin()
#include <string>
#include <map>
using namespace std;
class Inventory
{
public:
typedef map<string,string>::iterator iterator;
map<string,string>::iterator& begin()
{ return map_.begin(); } // *** ERROR HERE
private:
map<string,string> map_;
};
void f (string s)
{
}
int main (void)
{
Inventory invent;
Inventory::iterator i;
i = invent.begin();
return 0;
}
I can post the full text of the error message but it is rather
long. But in essense it says "cannot convert std::map...begin() to
std::_Rb_tree_iterator..."
I'm using gcc with the bloodshed environment.
Any suggestions greatfully accepted!
--
Nick Keighley
"Half-assed programming was a time-filler that, like knitting,
must date to the beginning of human experience."
"A Fire Upon The Deep" by Verne Vinge