I'm a little confused how to do this, I need to read in from a text file and then create a 'new Product' or 'new SaleProduct' depending if the first character is an 'R' or 'S' (regular/sale)
First we were told to create a vector which is vector(Product*) Inventory;
Then the example we were shown looks like this:
Code
inventory.push_back(new Product(descr, quantity, price));
inventory.push_back(new SaleProduct(descr, quantity, price, discount));
Now what I'm lost on, we have to distinguish if the first character in the file holds an R or S then do that push_back to the appropriate one (using an if statement i presume). But how do I do this when the file being read in, isn't even part of the vector yet? Sorry if this is confusing, tried explaining it the best i could.