Declare a variable of type iter
:
void Routes::viewroutes(){
typedef map<char*, char*>::const_iterator iter;
for (iter i =rtable.begin(); i != rtable.end(); ++i) {
cout << i->second << " " << i->first << endl;
}
}
Just for fun :), you can use the following functions which I wrote to stream the contents of a map or a multimap to any standard stream whether it is the standard output, a file stream. It deals with all types of streams like cout or wcout for example:
template <class Container, class Stream>
Stream& printPairValueContainer(Stream& outputstream, const Container& container)
{
typename Container::const_iterator beg = container.begin();
outputstream << "[";
while(beg != container.end())
{
outputstream << " " << "<" << beg->first << " , " << beg->second << ">";
beg++;
}
outputstream << " ]";
return outputstream;
}
template
< class Key, class Value
, template<class KeyType, class ValueType, class Traits = std::less<KeyType>,
class Allocator = std::allocator<std::pair<const KeyType, ValueType> > >
class Container
, class Stream
>
Stream& operator<<(Stream& outputstream, const Container<Key, Value>& container)
{
return printPairValueContainer(outputstream, container);
}