title: I dont quite understand why i am getting this error concerning vectors
body: <p>My program takes two input files, one of which is a list of commands. Each line of the file is a new command, so i want to parse this file into an array. I was told to use a vector as it dynamically grows which would eliminate the need for a function to count the number of lines in the file and then use that data to create an array. </p>
  
  <p>Here is what my program is right now:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;string&gt;
  #include&lt;fstream&gt;
  #include&lt;vector&gt;
  using namespace std;
  
  
  //Prototypes
  int parseLines(ifstream&amp; countfile);
  
  
  vector&lt;string&gt; parseLines(ifstream&amp; countfile)
  //counts number of lines in file passed to function
  {
     string line;
     vector&lt;string&gt; lines;
     int numberOfLines;
  
     //reads through each line until end of file putting each line in a sperate entry of the vector
     while(getline(countfile, line))
     {
         lines.push_back(line);
     }
  
     return lines;
  }
  
  
  int main (int argc, char* argv[])
  {
  
          int i;
  
      if(argc != 3) cout &lt;&lt; "Usage: calendar.out datafile inputfile";
  
      //Create input streams to both files
      ifstream apptsfp;
      ifstream inputfp;
  
      //Open streams to both files
      apptsfp.open(argv[1]);
      inputfp.open(argv[2]);
  
      if(!inputfp.is_open())
      {
          cerr &lt;&lt; "failed to open input file\n";
          return 1;
      }
  
          vector&lt;string&gt; inputVector;
          vector&lt;string&gt; apptsVector;
  
      inputVector = parseLines(inputfp);
  
          for(i=0; i&lt;= inputVector.size(); i++)
          {
          cout &lt;&lt; "Input " &lt;&lt; i &lt;&lt; ": " &lt;&lt; inputVector[i] &lt;&lt; endl;
          }
  
      return 0;
  }
  </code></pre>
  
  <p>And i am getting this long error when i compile and i dont quite understand it:</p>
  
  <pre><code>$ g++ calendar.cpp
  calendar.cpp: In function ‘std::vector&lt;std::basic_string&lt;char&gt; &gt; parseLines(std::ifstream&amp;)’:
  calendar.cpp:17:46: error: new declaration ‘std::vector&lt;std::basic_string&lt;char&gt; &gt; parseLines(std::ifstream&amp;)’
  calendar.cpp:14:5: error: ambiguates old declaration ‘int parseLines(std::ifstream&amp;)’
  calendar.cpp: In function ‘int main(int, char**)’:
  calendar.cpp:58:37: error: no match for ‘operator=’ in ‘inputVector = parseLines((* &amp; inputfp))’
  calendar.cpp:58:37: note: candidate is:
  In file included from /usr/include/c++/4.7/vector:70:0,
                   from calendar.cpp:9:
  /usr/include/c++/4.7/bits/vector.tcc:161:5: note: std::vector&lt;_Tp, _Alloc&gt;&amp; std::vector&lt;_Tp, _Alloc&gt;::operator=(const std::vector&lt;_Tp, _Alloc&gt;&amp;) [with _Tp = std::basic_string&lt;char&gt;; _Alloc = std::allocator&lt;std::basic_string&lt;char&gt; &gt;]
  /usr/include/c++/4.7/bits/vector.tcc:161:5: note:   no known conversion for argument 1 from ‘int’ to ‘const std::vector&lt;std::basic_string&lt;char&gt; &gt;&amp;’
  </code></pre>
  
  <p>I feel like i don't quite understand how to use vectors.</p>