Hello all,
I hope you all are doing well. I just received an email regarding you people facing difficulty
with doing assignment 2. So, in this email I will try my best to brief you all a little about what
the assignment basically requires you to do.
Before you begin the assignment just keep these few syntaxes in mind.
1) for (; file >> state >> dem >> rep;)
This for loop is simply reading the given file and storing the contents in three variables
state, dem and rep. Nothing more nothing less!
2) auto results = std::vector<std::tuple<std::string, double, double>>();
The above container results is a vector type container and all the subboxes inside it are
tuples. Every tuple has a string, and two doubles inside it.
Whenever you declare a large box which has type vector you need to use push_back to
insert values in it.
For instance, if I want to push anything to results.
results.push_back({“Urooj”,1.5,1.6});//The curly braces are used whenever we are
putting values in a tuple.
3)How do I access values stored inside the container results?
for(auto [x,y,z] :results)
{
}
There are multiple syntaxes to access but do not confuse yourself with them. Stick with
one method only!
4) auto state_edge = std::map<std::string, double>();
This is a container which is map type. As you know that map is a key value pair and in
the map state_edge key is type string and value is double type.
How do I insert values in the map state_edge?