So I have a class Product:
class Product : public Streamable {
char sku_[MAX_SKU_LEN + 1];
char * name_;
double price_;
bool taxed_;
int quantity_;
int qtyNeeded_;
}
I'll skip the irrelevant member functions. And this is my derived class from Product:
class AProduct : public Product {
char fileTag_;
char unit_[11];
public:
const char* unit() const;
}
I have an array of product pointers:
Product* product_[100];
This is an array of Product pointers which means it can also contain AProduct pointers. What can I do to access the unit_ of the elements of this array which are AProduct pointers?
Using (*Product[i]).unit() will result an error because unit() function is implemented in AProduct, and product_ is an array of Product pointers
Aucun commentaire:
Enregistrer un commentaire