Some misunderstandings

closed account (G1vDizwU)
Hi guys,

Please have a look at the codes below. The first one is a template class named list with another class inside itself (iterator). And the second, apparently the definition of iterator. I hadn't seen a class inside another one!

Would you please simple the meanings of the lines of both codes for me?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
template<class Elem> class list {
 //representation and implementation details

public:
  class iterator;  
  
  iterator begin();
  iterator end();
 
  iterator insert(iterator p, const Elem& v);
  iterator erase(iterator p);
  ..
  ..
  ..
  ..
   // ...
};


1
2
3
4
5
6
7
8
9
10
11
12
template<class Elem> class list<Elem>::iterator {
 Link<Elem>* curr;
 
 public:
 
 iterator(Link* p) : curr(p);

 // ...
  // ...
 
};


Last edited on
closed account (G1vDizwU)
Guys, my questions are these:
Is it possible to declare a class into another class!?
What is the meaning of (for example) iterator begin();?
And if declaring that iterator class is acceptable and right, what is the correct form of defining that?
Topic archived. No new replies allowed.