title: Nested iterator class, begin() and end() sentinel issues
body: <p>I am having issues with my nested iterator class. The end() sentinel is returning 0, and I am very lost! Any help would be appreciated. I want this program to be able to take any type of input, e.g. an int, create the vector, and be able to fill the array until the end() sentinel has been reached, such as typing Q, or any non-integer. I took out a few lines of unnecessary code to shorten it.</p>
  
  <pre><code>template &lt;class T&gt;
  class Set
  {
      private:
          vector&lt;T&gt; m_element;
          int size;
      public:
          Set() : size(0) {};
          ................
          ................
          ................
  
          class iterator;
          friend class iterator;
          class iterator
          {
              private:
                  int i_index;
                  Set&amp; s;
              public:
                  iterator(Set&amp; is) :s(is), i_index(0) {}
                  iterator(Set&amp; is, bool) : s(is), i_index(s.size) {}
                  int operator++()
                  {
                      return s.m_element[++i_index];
                  }
                  (other postfix ++ operator)
                  int current() const
                  {
                      return s.m_element[i_index];
                  }
                  ....................
                  bool operator!=(const iterator &amp;rv) const
                  {
                      return i_index != rv.i_index;
                  }
                  .............................
                  int getI()
                  {
                      return i_index;
                  }
          };
          iterator begin() { return iterator(*this);}
          iterator end() {return iterator(*this, true);}
  };
  
  template &lt;class T&gt;
  istream&amp; operator&gt;&gt; (istream &amp;in, Set&lt;T&gt; &amp;element)
  {
      T elementin;
      Set&lt;T&gt; is;
      class Set&lt;T&gt;::iterator it = element.begin();
      while(it != element.end())
      {
          in &gt;&gt; elementin;
          element.push(elementin);
      }
      return in;
  }
  
  int main()
  {
      Set&lt;int&gt; intset;
      Set&lt;int&gt;::iterator it = intset.begin();
      for(int i = 0; i &lt; 5; i++)
      {
          intset.push(i);
          cout &lt;&lt; it.getI();
          ++it;
      }
  
      cout &lt;&lt; endl &lt;&lt; intset.begin() &lt;&lt; intset.end();
  
      return 0;
  }
  
  OUTPUT:
  01234
  00
  </code></pre>