Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ map

#include <iostream>
#include <string>
#include <map>

using std::string;
using std::map;
map <int,string>MapName;//you can put type you want
map<int,string>::iterator iter;

int main(){
 	int i=31136;
  	string s="name;
//How you insert values
	MapName.insert(pair<int,string>(i,s));
//How you print keys and values 
  	for(iter=studentId.begin();iter!=studentId.end();iter++){
    	cout<<"Key"<<iter->first<<"Value: "<<iter->second<<endl;
    	}
//How you search data
  	if (m.find(31136) != m.end()) {
		cout << "found" << endl;
		}
	else {
		cout << "not found" << endl;
		}
	}
 
PREVIOUS NEXT
Tagged: #map
ADD COMMENT
Topic
Name
2+7 =