This is my code:
#include <string>
#include <vector>
namespace election {
// The election result struct is already created for you:
struct ElectionResult {
// Name of the candidate
std::string name{};
// Number of votes the candidate has
int votes{};
};
// TODO: Task 1
// vote_count takes a reference to an `ElectionResult` as an argument and will
// return the number of votes in the `ElectionResult.
int vote_count(ElectionResult& electionResult){
return electionResult.votes;
}
// TODO: Task 2
// increment_vote_count takes a reference to an `ElectionResult` as an argument
// and a number of votes (int), and will increment the `ElectionResult` by that
// number of votes.
void increment_vote_count(ElectionResult& electionResult, int moreVotes){
for (int i = 0; i < moreVotes; i++){
electionResult.votes ++;
}
}
// TODO: Task 3
// determine_result receives the reference to a final_count and returns a
// reference to the `ElectionResult` of the new president. It also changes the
// name of the winner by prefixing it with "President". The final count is given
// in the form of a `reference` to `std::vector<ElectionResult>`, a vector with
// `ElectionResults` of all the participating candidates.
ElectionResult& determine_result(std::vector<ElectionResult>& finalCount){
if(finalCount[0].votes > finalCount[1].votes){
finalCount[0].name = "President " + finalCount[0].name;
return finalCount[0];
}else{
finalCount[1].name = "President " + finalCount[1].name;
return finalCount[1];
}
}
} // namespace election
This is the error I am getting:
make[2]: *** [CMakeFiles/test_election-day.dir/build.make:70: CMakeFiles/test_election-day] Error 3
make[1]: *** [CMakeFiles/Makefile2:111: CMakeFiles/test_election-day.dir/all] Error 2
make: *** [Makefile:91: all] Error 2