I have the SuperClass called Transaction, it has methods:
- Type
- Guid
- Customer
then the subclass called Order has these methods:
- item
- quantity
- cost ...
so Order inherits from Transaction.
My problem is that there can be multiple types of transactions... Orders, Payment, etc.
Therefore i hold every type of transaction in the array like this:
Transaction trans[100];
trans[0] = Order order(val,val,val);
trans[1] = Order order(val,val,val);
trans[2] = Order order(val,val,val);
...
But now when i call trans[3].Get_item();
i get error that Transaction class has no method Get_item
, yes it doesn't but what it's holding has.
I have tried making array an array of pointers and accessing using ->
operator. But the problem persists.
Real Code ::::::
vector<Transaction *> trans;
....
Order order(words[0], words[1], words[2], words[3], words[4], words[5]);
trans.push_back(&order);
....
trans[i]->Getitem(); //error here.