Implementing list and vector
I don't want to define itterator, which is an internal class of two classes, so I define it separately.
I'd like to refer to it, is there a way?
c++ data-structure
typedef
allows you to put a type name inside the class.
class Iterator {
// ...
};
class list {
public:
typedef Iterator iterator;
};
class vector {
public:
typedef Iterator iterator;
};
Alternatively, you can define an externally declared class in the following ways:
class vector {
public:
class iterator;
};
class vector::iterator {
// ...
};
© 2024 OneMinuteCode. All rights reserved.