Hello guys,
I have a problem again with my lecturer's task she has given, I feel it is wrong at all.
Here is what she gave us:
in the Account.h attributes
but so far this is just a pointer to pointer, isn't it?
then in Account.cpp :
Can anyone explain what's going on here? I understand that she is declaring an array or pointers through a pointer Transactions, and then allocates an object for each pointer, but is it right to access the array like that?
I have a problem again with my lecturer's task she has given, I feel it is wrong at all.
Here is what she gave us:
in the Account.h attributes
Code:
Transaction **Transactions; // she called this 'declaring an array Transactions'
then in Account.cpp :
Code:
Account :: Account()
{
Transactions = new Transaction *[SizeOfArray];
for (int i=0; i<SizeOfArray; i++)
Transactions[i] = new Transaction(); ///is this right access of array elements?
}
Account :: ~Account()
{
for (int i=0; i<SizeOfArray; i++)
delete Transactions[i];
delete Transactions;
}
Comment