Search
 
SCRIPT & CODE EXAMPLE
 

CPP

map declaration c++

//assuming your variables are called : variables_
#include <map>
#include <string>

std::map<int, std::string> map_;
map_[1] = "mercury";
map_[2] = "mars";
map_.insert(std::make_pair(3, "earth"));
//either synthax works to declare a new entry

return map_[2]; //here, map_[2] will return "mars"
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to sort in descending order in c++ 
Cpp :: loop through array c++ 
Cpp :: C++ Area and Perimeter of a Rectangle 
Cpp :: iterate over vector in c++ 
Cpp :: c++ cast to type of variable 
Cpp :: c++ remove element from vector 
Cpp :: initialize string with length c++ 
Cpp :: how to append to a vector c++ 
Cpp :: Reverse Level Order Traversal cpp 
Cpp :: inline function in c++ 
Cpp :: cpp vs c# 
Cpp :: Header for INT_MIN 
Cpp :: length of string in c++ 
Cpp :: implementing split function in c++ 
Cpp :: substr in cpp 
Cpp :: temperature conversion in c++ 
Cpp :: best websites for programming 
Cpp :: how to get hcf of two number in c++ 
Cpp :: c++ compile to exe 
Cpp :: set to vector 
Cpp :: how to remove first element from vector c++ 
Cpp :: find a number in vector c++ 
Cpp :: string format decimal places c++ 
Cpp :: initialize a vector to 0 
Cpp :: string comparison c++ 
Cpp :: oop in cpp 
Cpp :: how to get euler constant in c++ 
Cpp :: loop execution decending order in c 
Cpp :: how to write int variable c++ 
Cpp :: opencv compile c++ 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =