Afficher un message
Vieux 18/10/2007, 08h29   #1
wangxiaohu
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut How to use the iterator from base class in a derived class?

I am trying to write a class myVector based on std::vector and add
only a sort method. The sort method needs to access the array stored
in the base class using iterator. I have following draft code. However
it never compile. Can anyone take a look and tell me how to fix it?
Thanks!

#include <vector>
#include <iostream>

using namespace std;

template <typename T> class myVector : public vector<T>
{
public:
void Sort();
};

template <typename T> void Sort<T>::Sort()
{
if (this.size() < 2)
{
return;
}

vector<T>::iterator i;

for (i = this.begin(); i != this.end(); i++)
{
//rest part ignored....
}
}

  Réponse avec citation
 
Page generated in 0,04267 seconds with 9 queries