I am trying to finish this program but have run into a problem. There is an erro
ID: 3635971 • Letter: I
Question
I am trying to finish this program but have run into a problem. There is an error that I do not know how to solve. The error is:error C2664: 'void std::list<_Ty>::insert<std::_List_iterator<_Mylist>>(std::_List_const_iterator<_Mylist>,_Iter,_Iter)' : cannot convert parameter 1 from 'int' to 'std::_List_const_iterator<_Mylist>'
The error points to the line with - first.insert(rand()%5); - specifically the period between first and insert.
Code:
#include <iostream>
#include <list>
#include <tchar.h>
using namespace std;
int countValue(list<int> front ,const int item);
int _tmain(int argc, _TCHAR* argv[])
{
list<int> first;
int listCount;
cout << "Enter the size of the list: ";
cin >> listCount;
for (int i = 1; i <= listCount; i++)
first.insert(rand()%5);
cout << "Original List of Values: " << endl;
//writeLinkedList(front, " ");
cout << endl;
for(int j=0;j<5;++j)
cout << countValue (first,j) << endl;
cout << endl;
return 0;
}
int countValue(list<int> front, const int item)
{
for(list<int>::iterator i = front.begin(); i != front.end(); i++)
cout << *i << " ";
cout << endl;
}
Note** I have not finished the code for int countValue.
Explanation / Answer
instead of int declare float and then try
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.