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
this first chunk of code is used to call the method in my analyser class
std::string *topBuyers = analyser.topFiveBuyers();
for(int idx = 0; idx < 5; idx++)
std::cout << "Top buyer" << (idx+1) << ": " << topBuyers[idx] << std::endl;
std::cout << std::endl;
delete [] topBuyers;
the next portion of code is the method in question.
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;
}