I'm getting some error when compiling this code, could any one help me understand how to make primatives members of the iterator?
template <class Type>
void perfectShuffle(linkedListType<Type>& list)
{
linkedListIterator<int> tmp1; // Use for the topHalf of the list
linkedListIterator<int> tmp2; // Use for the lowerHalf of the list
int length = list.length();
int i =0;
for ( linkedListIterator<int> itr = list.begin(); itr != list.end(); ++itr)
{
if( i <= length/2) {
//the first half contain elements
tmp2.insertLast(*itr);
}
else {
tmp2.insertLast(*itr);
}
}
//now shuffle the list using the temperary nodes
list.destroyList();
for ( linkedListIterator<int> itr = tmp2.begin(); itr != tmp2.end(); ++itr) {
list.insertFirst(*itr); //insert the first one last, i.e last one becomes first one
}
for ( linkedListIterator<int> itr = tmp1.begin(); itr != tmp1.end(); ++itr) {
list.insertFirst(*itr); //insert the first one last, i.e last one becomes first one
}
return;
}
error C2039: 'insertLast' : is not a member of 'linkedListIterator<Type>'
1> with
1> [
1> Type=int
1> ]
also same error for begin and end
and this error:
1> see reference to function template instantiation 'void perfectShuffle<int>(linkedListType<Type> &)' being compiled
1> with
1> [
1> Type=int
1> ]