I have some code which is using std::map iterators in a manner similar to pointers. I have a wrapper class around the iterator which facilitates pulling elements out of them. The problem is, when I compile, I get the error "no appropriate default constructor available".
Code:typedef std::map<int, int> foo; class FooElem { foo::const_iterator ci; public: FooElem (foo::const_iterator const & iter) : ci(iter) { } std::string getId() { return ci->first; } int getAge() { return ci->second; } };
So, what I want to do is add a constructor like this...
But... that clearly won't work. What can I do to get this effect? The best I can think of is to use a pointer to the iterator, but it seems like there should be a way to just make a zero-iterator or something.Code:FooElem() : ci(NULL?) { }



LinkBack URL
About LinkBacks



