title: C++ overloaded operator []
body: <p>I have made a application where you type the amount of books you want to enter and using overloaded operator ([]) but every time I give a pointer to store an array, it gives me an errors such as</p>
  
  <blockquote>
    <p>2 IntelliSense: expression must have integral or unscoped enum
    type      Line:11 Column:24   Library Books</p>
  </blockquote>
  
  <p>and </p>
  
  <blockquote>
    <p>Error 1   error C2440: 'initializing' : cannot convert from
    'std::string' to 'unsigned int'       Line:11 Column:1    Library Books</p>
  </blockquote>
  
  <p>but anyway here is my code: </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  class Books{
  private:
      string* storage;
      string book;
  public:
      Books(){
          storage = new string[book];
      }
      void savebooks(int iterate){
          for (int i = 0; i &lt; iterate; ++i){
              cout &lt;&lt; "Book: ";
              getline(cin, storage[i]);
          }
      }
  
      const string operator[](const int ref){
          return storage[ref];
      }
      ~Books(){
          delete storage;
      }
  };
  
  int main(){
      //local variables 
      int quantity;
      //user display
      cout &lt;&lt; "Welcome to Book Storage Viewer" &lt;&lt; endl;
      cout &lt;&lt; "How many books would you like to insert: ";
      cin &gt;&gt; quantity;
      //instantiante 
      Books bk;
      //other handle
      bk.savebooks(quantity);
      //display books
      cout &lt;&lt; "These are the books you've entered" &lt;&lt; endl;
      for(int i = 0; i &lt; quantity; ++i){
          cout &lt;&lt; bk[i] &lt;&lt; endl;
      }
      system("pause");
      return 0;
  }
  </code></pre>
  
  <p>also I am not 100% sure if I have coded this correctly and if there are anymore errors please tell me and thanks.</p>