c++ - Access violation reading location 0xcccccccc
<p>I am using an object called tArray which is an array of objects and does work correctly to perform all the other tasks. I need to form an array of strings using buyerName from the array of objects to fill it our new array and then return it. however I keep getting the error as stated in my title, does anyone know why? I am struggling on only this method on my program so far. thanks</p>

<p>this first chunk of code is used to call the method in my analyser class</p>

<pre><code>std::string *topBuyers = analyser.topFiveBuyers();
for(int idx = 0; idx &lt; 5; idx++)
    std::cout &lt;&lt; "Top buyer" &lt;&lt; (idx+1) &lt;&lt; ": " &lt;&lt; topBuyers[idx] &lt;&lt; std::endl;
std::cout &lt;&lt; std::endl;
delete [] topBuyers;
</code></pre>

<p>the next portion of code is the method in question.</p>

<pre><code>string* Analyser::topFiveBuyers()
{
const int sSize = 5;

string calcString[sSize] = {tArray[0].buyerName, tArray[1].buyerName, 
tArray[2].buyerName, tArray[3].buyerName, tArray[4].buyerName}; 

return calcString;
}
</code></pre>
