Hi All,
I'm new to C++. I need some help regarding the usage of map STL container. I've declare map proteinData in the below header file. ProteinData contains key as integer and value as a struct.
#ifndef _READFILE_H_
#define _READFILE_H_
#include<string>
#include<vector>
#include<map>
There are many reasons not to store an iterator in your class.
1. Some class operation may invalidate the iterator.
2. Using a local iterator contrains the object to be used by one client, which is unncessary and probably wrong.
You can traverse the map as:
1 2
for (map<int, Readfile::Info>::const_iterator p = myfile->proteinData.begin(); p != myfile->proteinData.end(); ++p)
std::cout << p->first << std::endl;