How do I let the program calculate the sum of value and retrieve the match person. If both of the individuals reach sum of total value, they are matched. Like if total value is 300. If person 1 has 100 and person 2 has 200, they match. Otherwise they are not. If match, the user can enter a name and output will display the matched people or else the other statement.
Please post real code instead of this uncompilable garbage.
members.cpp: In function ‘int main()’:
members.cpp:24:30: error: ‘criterion’ was not declared in this scope
while (infile >> name >> criterion >> phone){
^
members.cpp:33:5: error: expected ‘;’ before ‘getline’
getline (cin, entername);
^
members.cpp:37:59: error: ‘struct members’ has no member named ‘criterion’
cout << it-> second. name << "\t" << it -> second.criterion
^
members.cpp:48:13: error: ‘currCriterion’ was not declared in this scope
currCriterion = it-> second. crit;
^
members.cpp:49:13: error: ‘sumCriterion’ was not declared in this scope
sumCriterion = totalCrit - currCrit;
^
What is it that doesn't work with the code? Saying something compiles but doesn't work isn't helpful.
With the forwarding reference in the for loop, I had 2 & , as in :
for (auto&& map_criterion : mem_map)
It won't make any difference in this example, 1 & means pass by reference, 2 means a forwarding reference which will work with lvalues, rvalues, const and non const. Google it if you are interested.
Thanks I have updated the code below.The program is only displaying the first individual when I try to display everyone. When a username is entered is this the right way to find person?
Should I store int current_criterion , int match_criterion = 500, int desired_criterion in vector?
Well try to use the debugger. Hopefully there is a GUI one in your IDE. Set up a watch list of variables, step through the program line by line, deduce what goes wrong.
where does the article explain about [Inferior 1 (process 31434) exited normally]? debugger is producing no stack with backtrace so i dont know where to narrow it down.