title: Recursive function building a vector, what will be returned?
body: <p>so I'm trying to build a vector recursively, as I look at this I begin to think I'm doing it quite wrong. Will the following code return a vector with each iterations results, or am I just creating new vectors on each iteration that actually wont build on each recursive call. If I'm wrong, how do I go about building a vector recursively... Thanks in advance for your constructive help!</p>
  
  <pre><code>std::vector&lt;ParameterClass&gt; recursiveParser :: parseParamList()
  {
    std::vector&lt;ParameterClass&gt; paramVector;
  
    if (lexicator-&gt;getCurrentToken()-&gt;getTokenType() == STRING) {
  
      paramVector.push_back(ParameterClass(*lexicator-&gt;getCurrentToken()));
      lexicator-&gt;advance();
      parseParamList();
  
    } else if (lexicator-&gt;getCurrentToken()-&gt;getTokenType() == ID) {
  
      paramVector.push_back(ParameterClass(*lexicator-&gt;getCurrentToken()));
      lexicator-&gt;advance();
      parseParamList();
  
    } else {
  
    // so as to not fail in Expression, i need to check to see that there is a
    // left paren indicating that there should be an expression
  
      if (lexicator-&gt;getCurrentToken()-&gt;getTokenType() == LEFT_PAREN) {
        paramVector.push_back(ParameterClass(parseExpression()));
        lexicator-&gt;advance();
        parseParamList();
      }
    }
    return paramVector;
  }
  </code></pre>