How do I print this array?
Hi! I'm still quite new to c++ and I've found a problem with one of my projects. So I have this array
1 2 3 4 5 6 7 8
|
void Interface::vecProd(){
Product *p;
p=new Product [1];
p[0].setName("Meat");
p[0].setPrice(20);
p[1].setName("Spaghetti");
p[1].setPrice(15);
}
|
How do I call the name ("Meat") and price (20) so I can print them?
You would add an accessor to the Product class that returns the name and another that returns the price.
Topic archived. No new replies allowed.