Question: Fix c++ error: 'function#' was not declared in this scope. (I can't figure out how to fix the parameter, full code is not need. just
Fix c++ error: 'function#' was not declared in this scope. (I can't figure out how to fix the parameter, full code is not need. just help witht the parameters)
From fuction.h file:
void function1(map, int> &m,tuple &t,int &value); void function2(map, int> &m,tuple &t,int &value); void function3(map, int> &m,tuple
From function.cpp:
void function1(map, int> &m,tuple &t,int &value) { for(auto itr=m.begin();itr!=m.end();itr++) { t = itr->first; value = itr->second; cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << " " << value << endl; }
void function2(map, int> &m,tuple &t,int &value) { for(auto itr=m.rbegin();itr!=m.rend();itr++) { t = itr->first; value = itr->second; cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << " " << value << endl; } }
void function3(map, int> &m,tuple &t,int &value, vector > freq_vec, tuple freq_t){ for(auto itr=m.begin();itr!=m.end();itr++) { t = itr->first; value = itr->second; freq_t = make_tuple(get<0>(t), get<1>(t), get<2>(t), value); freq_vec.push_back(freq_t); } // sort this vector based on value (in map) sort(freq_vec.begin(),freq_vec.end(),my_compare); // output vector in ascending order for(int i=0;i freq_t = freq_vec[i]; cout << get<0>(freq_t) << " " << get<1>(freq_t) << " " << get<2>(freq_t) << " " << get<3>(freq_t) << endl; } }
From main.cpp:
// Now output based on option provided if(option.compare("a") == 0) { function1(m,t,value); } else if(option.compare("r") == 0) { function2(m,t,value); } else if(option.compare("c") == 0) { function3(m,t,value,freq_vec, freq_t); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
