hello every one , why do i get this error ,would any one tell me the reason?
(probably im doing it the wrong way ,as it may be understood from the codes im trying to access a mapped array elements through a while loop (do it till you havent reached the end of the array) . here is the codes ,(sorry for indentation)
before i post the codes , here is the error i got :
C:\Documents and Settings\Master\My Documents\Goldedition\charpointer2.cpp|
27|error: base operand of `->' has non-pointer type `std::map<int, std::string, std::less<int>, std::allocator<std:air<const int, std::string> > >'|
any answer is greatly appreciated .Code:#include <cstdlib> #include <iostream> #include <map> using namespace std; int main() { char memory[5][4]={0}; char memory1[5][4]={0}; char * bred="1101"; char *red="red"; char *lda="lda"; char *blda="1001"; char *sta="sta"; char *ptr; string ptr1;//for testing only map<int,string>::iterator it; map<int,string> commandregister;// is used to store the latest int i=0,c=0,k=0; bool ok=true; commandregister[0]=red; commandregister[1]=lda; commandregister[2]=sta; while ( (*it) != commandregister.end() ) { if ((*it).second ==red ) { cout<<"yes"<< endl; for(int i=0;i<4;i++) memory[k][i]=*(bred+i); cout <<"we have red "; for (int j=0;j<4;j++) cout<<memory[k][j]; } k++; // else //else cout<<"no"; if ((*it).second ==lda ) { cout<<"yes"<< endl; for(int i=0;i<4;i++) memory[k][i]=*(blda+i); cout <<"we have lda "; for (int j=0;j<4;j++) cout<<memory[k][j]; } it++; //next element } // cout<<endl; for (int k=0;k<5;k++) { for (int j=0;j<4;j++) { cout<<memory[k][j]; } } system("PAUSE"); return EXIT_SUCCESS; }



LinkBack URL
About LinkBacks
air<const int, std::string> > >'|




