Hey all,
I am tryin to cut down the size of my program by creating a new class to perform certain operations.
I would like to declare an array in my main, pass the array to EACH function in the new class, and have some value be inserted into the same array and be saved.
My main is such:
Code:
SoldItem *sold = new SoldItem[5];
int main()
{ some code }
void mainFunction()
{
OperateSold *OS = new OperateSold(); // My helper function
OS->amountSold(sold);
sold[i].getAmountSold(); // will this return the same aount set?
}
THe OperateSold class would have many functions, such as:
Code:
OperateSold::OperateSold(){ }
OperateSold::~OperateSold() { }
void OperateSold::amountSold(SoldItem *sold)
{
char amount;
cout<< "Enter amount: ";
cin >> amount;
sold[i].setAmountSold(amount);
....code.....
}
Will this properly insert the char amount into the sold array, and if the sold array is reference in main after the amountSOld function call, will the amount be in the same sold array, or somewhere else in memory.
DO i need to return a pointer to the array??
Or is the passing SoldItem pointer going to insert the char amount in the proper memory location for the array.
THanks very much