#ifndef _READFILE_H_
#define _READFILE_H_

using namespace std;

class Readfile{

string str;
vector <string> goArray;
vector <string> strArray;
vector <string> phyIntArray;
vector <string> subArray;
vector <string> proArray;
/* member function */
void processString(string str);
void processGoId(string);
void processPhysicalInt(string);
// void processMetabolicInt(string);

typedef struct Info{
string uniprotID;
vector <string> goId;
vector <string> phyInt;

map <int,struct Info> proteinData;
map <int,struct Info>::iterator it;

Readfile(string file);//constructor


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. 
Can any one help me how to access map outside the class defination.

Thanks in advance
8 Years
Discussion Span
Last Post by gauravkr

I'm accessing map proteinData inside the
ini main(){
Readfile *myfile=new Readfile(argv[1]);
cout << myfile->proteinData << endl;

I'm getting an error:
no match for ‘operator<<’ in ‘std::cout << myfile->Readfile::proteinData’.

i'm clueless about the error.


'm able to get the size of the map container proteinData, shown in the below code.

Readfile *myfile=new Readfile('foo.txt');
cout << "this is iterator:" << endl;
cout << myfile->proteinData.size()<< endl;

for(myfile->it=myfile->proteinData.begin(); myfile->it=myfile->proteinData.end();myfile->it++){
cout << myfile->it->first << endl;

but couldn't access the iterator defined inside the class, giving an error message

could not convert ‘(myfile->Readfile::it <unknown operator> ((const std::_Rb_tree_iterator<std::pair<const int, Readfile::Info> >&)((const std::_Rb_tree_iterator<std::pair<const int, Readfile::Info> >*)(& myfile->Readfile::proteinData.std::map<_Key, _Tp, _Compare, _Alloc>::end [with _Key = int, _Tp = Readfile::Info, _Compare = std::less<int>, _Alloc = std::allocator<std::pair<const int, Readfile::Info> >]()))))’ to ‘bool’.

I think there is something wrong with defining the iterator inside class.

Can anyone help with this.......

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.