P
PengYu.UT
Hi,
I'm wondering why typename can not be inherented from base class. An
example is shown below. If I have to typedef value_type anyway, I think
it would be easier to define the 5 types in iterator like "typedef T
value_type" without inherent from std::iterotor.
Thanks,
Peng
#include <iterator>
template <typename T>
class iterator : public std::iterator<std::random_access_iterator_tag,
T> {
public:
typedef typename std::iterator<std::random_access_iterator_tag,
T>::value_type value_type;//this line can not be deleted
private:
value_type v;
};
int main(){
iterator<int> it;
}
I'm wondering why typename can not be inherented from base class. An
example is shown below. If I have to typedef value_type anyway, I think
it would be easier to define the 5 types in iterator like "typedef T
value_type" without inherent from std::iterotor.
Thanks,
Peng
#include <iterator>
template <typename T>
class iterator : public std::iterator<std::random_access_iterator_tag,
T> {
public:
typedef typename std::iterator<std::random_access_iterator_tag,
T>::value_type value_type;//this line can not be deleted
private:
value_type v;
};
int main(){
iterator<int> it;
}