i have problems to understand the following source code. It would be very nice when you could write to each line what Funktion it has. Thank you very much :)
#include <iostream> // for using cout
#include <list> // for using lists
usingnamespace std; // for std functions
typedef list<int>INTLIST;
void display(list<int>);
int main()
{
int i;
list<int>list1;
INTLIST list2;
// Filling the list with random numbers
for(i=0;i<4;i++)
{
list1.push_back(rand()%10);
list2.push_back(rand()%10);
}
display(list1); // Display the list
display(list2);
// Putting first element to the end as well
list1.push_back(list1.front());
list1.reverse(); // Reverse list
list1.sort(); // Sort list
list1.merge(list2); // Merge two lists
list1.sort(); // Remove multiple entries #1
list1.unique(); // Remove multiple entries #2
return 0;
}
void display(list<int>my_list)
{
int i;
list<int>::const_iterator iterator;
iterator = my_list.begin();
while(iterator != my_list.end())
{
i = *iterator;
cout << i << endl;
++iterator;
}
}
Thank you for the very helpful link. I sadly cant find an explanation for "void display(list<int>);" and "void display(list<int>my_list)". Could you explain me what funktion they have?