Hi,
As you can see I have used pair for two type of data in a list here is my simple code and i intend to:
1.Initial my list to five space with all char = a and all int = 3.
2. use an iterator
I can use these feature in the way the list is not paired.how can make seam thing in the pair style?!
It did not work and gave me an huge error. I think it's not possible to define pair List like non-pair list and in this case I must define m own iterator. :( Isn't it?
It works. But line 7 is still wrong. The interface must be the same as line 6
1 2 3 4 5 6 7 8 9 10 11
#include<iostream>
#include<list>
usingnamespace std;
int main(){
list< pair< char, int> > myList(10,'c',3);
list< pair< char, int> >::iterator p = myList.begin(); // Here it must be pair as well
// cout<<myList.front().first<<endl;
return 0;
}
#include<iostream>
#include<list>
usingnamespace std;
int main(){
list< pair< char, int> > myList(10,pair< char, int>('c',3)); // Indeed pair
list< pair< char, int> >::iterator p = myList.begin(); // Here it must be pair as well
// cout<<myList.front().first<<endl;
return 0;
}