I have an unordered map containing one class instance per key. Each instance contains one private variable called source and a getter function called getSource().
My goal is to traverse the map, using my getter function to print the variable from each class instance. In terms of output formatting, I would like to print one variable per line. What is the proper print statement to accomplish this?
unordered_map declarations:
unordered_map<int, NodeClass> myMap; // Map that holds the topology from the input file
unordered_map<int, NodeClass>::iterator mapIterator; // Iterator for traversing topology map
unordered_map traversal loop:
// Traverse map
for (mapIterator = myMap.begin(); mapIterator != myMap.end(); mapIterator++) {
// Print "source" class variable at current key value
}
getSource():
// getSource(): Source getter
double NodeClass::getSource() {
return this->source;
}