C++ how to pass vector of objects by reference into a function, then into next function? : <p>I'm hoping somebody can provide some assistance here.  Here is the relevant portion of the code I'm stuck on currently:</p>

<pre><code>///////////////////////////////////////////////////////////////////////////////////////////////////
void matchBlobs(std::vector&lt;Blob&gt; &amp;existingBlobs, std::vector&lt;Blob&gt; &amp;currentFrameBlobs) {

    for (auto &amp;existingBlob : existingBlobs) {
        existingBlob.blnCurrentMatchFoundOrNewBlob = false;
    }

    for (auto &amp;currentFrameBlob : currentFrameBlobs) {

        int intIndexOfLeastDistance = 0;
        double dblLeastDistance = 1000000.0;

        for (unsigned int i = 0; i &lt; existingBlobs.size() - 1; i++) {
            if (existingBlobs[i].blnStillBeingTracked == true) {
                double dblDistance = distanceBetweenBlobs(currentFrameBlob, existingBlobs[i]);

                if (dblDistance &lt; dblLeastDistance) {
                    dblLeastDistance = dblDistance;
                    intIndexOfLeastDistance = i;
                }
            }
        }

        if (dblLeastDistance &lt; currentFrameBlob.dblDiagonalSize * 1.5) {
            addBlobToExistingBlobs(currentFrameBlob, existingBlobs, intIndexOfLeastDistance); // !!!! compiler error for 2nd arg on this line !!!!!!!
        } else {
            addNewBlob(currentFrameBlob, existingBlobs);
        }

    }

    for (auto &amp;existingBlob : existingBlobs) {
        if (existingBlob.blnCurrentMatchFoundOrNewBlob == false) {
            existingBlob.blnStillBeingTracked = false;
        }

    }

}

///////////////////////////////////////////////////////////////////////////////////////////////////
void addBlobToExistingBlobs(Blob &amp;currentFrameBlob, std::vector&lt;Blob&gt; &amp;existingBlobs, int &amp;intIndex) {

    existingBlobs[intIndex].contour = currentFrameBlob.contour;
    existingBlobs[intIndex].boundingRect = currentFrameBlob.boundingRect;
    existingBlobs[intIndex].ptCurrentCenter = currentFrameBlob.ptCurrentCenter;
    existingBlobs[intIndex].dblDiagonalSize = currentFrameBlob.dblDiagonalSize;
    existingBlobs[intIndex].dblAspectRatio = currentFrameBlob.dblAspectRatio;

    existingBlobs[intIndex].vectorOfAllActualPoints.push_back(currentFrameBlob.ptCurrentCenter);

    existingBlobs[intIndex].blnStillBeingTracked = true;
    existingBlobs[intIndex].blnCurrentMatchFoundOrNewBlob = true;
}
</code></pre>

<p>As noted on the comment in the code, I'm getting a compiler error on this line:</p>

<pre><code>addBlobToExistingBlobs(currentFrameBlob, existingBlobs, intIndexOfLeastDistance); // !!!! compiler error for 2nd arg on this line !!!!!!!
</code></pre>

<p>the error is:</p>

<pre><code>Error C2664 'void addBlobToExistingBlobs(Blob &amp;,Blob &amp;,int &amp;)': cannot convert argument 2 from 'std::vector&lt;Blob,std::allocator&lt;_Ty&gt;&gt;' to 'Blob &amp;'  ObjectTrackingCPP   c:\users\cdahms\documents\visual studio 2015\projects\objecttrackingcpp2\objecttrackingcpp.cpp  186
</code></pre>

<p>Can anybody shed some light on what I'm doing wrong here?  I can find plenty of C++ examples of passing one basic data type variable (int, double, etc.) by reference but I am unable to find any examples involving passing a vector of objects into one function, then into another function.</p>

<p>I'm using the compiler that ships with Visual Studio 2015 Community, with the default options chosen if that makes a difference.</p>

<p>I'm not sure what direction to go here, any assistance would be greatly appreciated.</p>
