title: Custom stream object error?
body: <p>I'm trying to write a program that:<br> </p>
  
  <blockquote>
    <p>parses text, removes pre-specified (punctuation) characters and creates a alphabetically ordered dictionary containing the parsed words from the text, which are then displayed on the screen. From <em>Bjarne Stroustup's C++ Programming: Principle and Practice</em> </p>
  </blockquote>
  
  <p>Here is what I've written:</p>
  
  <p><strong><code>Chapter11Exercise7Execute.cpp</code></strong></p>
  
  <pre><code>#include "stdAfx.h"
  #include "Chapter11Exercise7.h"
  
  const string endInput("x");
  
  int main(){
  try{
      // instantiate a PunctStream object and initialize it to: cin
      PunctStream ps(cin);
      // construct initial set of characters to be replaced with whitepace 
      ps.whitespace(",");
      // set case sensitivity
      ps.caseSensitive(false);
  
      string word;
      vector&lt;string&gt; dictionary;
      do{
          cout &lt;&lt; "Type a word\n&gt;&gt;";
          cin &gt;&gt; word;
  
          createDictionary(ps, dictionary);
          printDictionary(dictionary);            
      }while(word != endInput);
   }catch(exception&amp; e){
      cerr &lt;&lt; e.what() &lt;&lt; endl;
      getchar();
   }
   return 0;
   }
  </code></pre>
  
  <p><strong><code>Chapter11Exercise7.h</code></strong></p>
  
  <pre><code>#include "stdAfx.h"
  #ifndef _Chapter11Exercise7_H
  #define _Chapter11Exercise7_H
  
  class PunctStream{
  public:
      // constructors
      PunctStream(istream&amp; is): source(is), sensitive(true){ }
      // member-functions
      // creates a set of characters to be searched and replaced with whitespace
      void whitespace(const string&amp; s){white = s;}; 
      void addWhitespace(char c){white += c;};
      bool isWhitespace(char c);
      // set case sensitivity
      void caseSensitive(bool b){sensitive = b;};
      bool isCaseSensitive(){return sensitive;};
      // overwritten extraction operator
      PunctStream&amp; operator&gt;&gt;(string&amp; s);
      // operator that returns a bool value on success/failure of PunctStream object  
      operator bool();
  private:
      // stream containing text to be parsed
      istream source;
      // stringstream containing a parsed text
      istringstream buffer;
      // case sensitivity 
      bool sensitive;
      // characters to be replaced with whitespace
     string white;
   };
   // Non-member functions
   void createDictionary(PunctStream&amp; ps, vector&lt;string&gt;&amp; d);
   void printDictionary(vector&lt;string&gt;&amp; d);
   #include "Chapter11Exercise7V1.cpp"
   #endif
  </code></pre>
  
  <p><strong><code>Chapter11Exercise7.cpp</code></strong></p>
  
  <pre><code> #include "Chapter11Exercise7.h"
  
   // Member functions definition
   bool PunctStream::isWhitespace(char c){
      for(size_t i; i &lt; white.size(); i++) if (c == white[i]) return true;
     return false;
   }
   // Overwritten operators definition
   PunctStream&amp; PunctStream::operator&gt;&gt;(string&amp; s){
      while(!(buffer &gt;&gt; s)){
      // if buffer bad() or source not food =&gt; return PunctStream object
      // this is a pointe to the object in context
      if(buffer.bad() || !source.good()) return *this;
      buffer.clear();
  
      string line;
      // get a line from source
      getline(source, line);
      // replace "white" characters in "line"
      for(size_t i = 0; i &lt; line.size(); ++i){
          if(isWhitespace(line[i])) line[i] = ' ';
          // if case sensitivity is set =&gt; convert to lowercase
          else if (!sensitive) line[i] = tolower(line[i]);
      }
      // initialize the stringstream buffer to "line"
      buffer.str(line);
    }
    return *this;
  }
  
   PunctStream::operator bool(){
      // to return true: fail() and bas() should be unset, good()-set
      return !(source.fail() || source.bad()) &amp;&amp; source.good();
   }
   // Non-member functions
   void createDictionary(PunctStream&amp; ps, vector&lt;string&gt;&amp; d){
     string word;
     while(ps &gt;&gt; word) d.push_back(word);
  
     sort(d.begin(), d.end());
   }
  
   void printDictionary(vector&lt;string&gt;&amp; d){
     for(size_t i = 0; i &lt; d.size(); ++i) cout &lt;&lt; d[i] &lt;&lt;'\n';
   }
  </code></pre>
  
  <p><strong>The error I'm getting is the following:</strong></p>
  
  <pre><code>1&gt;------ Build started: Project: bjarneStroustroupC, Configuration: Debug Win32 ------
  1&gt;  Chapter11Exercise7Execute.cpp
  1&gt;c:\program files (x86)\microsoft visual studio 10.0\vc\include\istream(860): error C2248: 'std::basic_ios&lt;_Elem,_Traits&gt;::basic_ios' : cannot access private member declared in class 'std::basic_ios&lt;_Elem,_Traits&gt;'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          c:\program files (x86)\microsoft visual studio 10.0\vc\include\ios(176) : see declaration of 'std::basic_ios&lt;_Elem,_Traits&gt;::basic_ios'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  1&gt;          This diagnostic occurred in the compiler generated function 'std::basic_istream&lt;_Elem,_Traits&gt;::basic_istream(const std::basic_istream&lt;_Elem,_Traits&gt; &amp;)'
  1&gt;          with
  1&gt;          [
  1&gt;              _Elem=char,
  1&gt;              _Traits=std::char_traits&lt;char&gt;
  1&gt;          ]
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p><strong>I've read the error message, but it doesn't ring any bell. Any insight or advice is welcome!</strong></p>