I have a couple of questions I wanted to check with SO for my Data Structures in C++ course. They deal with the following class and multidimensional array:
class Order
{
public:
Order();
void addItem(string name, double price);
private:
static const int MAX_ITEMS = 10;
string itemNames[MAX_ITEMS];
int numItems; // # of items actually stored
double totalPrice;
};
const int TABLES = 10;
const int SEATS = 4;
Order diningRoom[TABLES][SEATS];
Q1: How many copies of MAX_ITEMS
does the array diningRoom
contain?
This is 40 right? There is one copy for each element in the array, 10*4.
Q2: Member function addItem
should have been instead declared how?
A.) void addItem(const string &name, double price);
B.) void addItem(string &name, double price);
C.) void addItem(string name, double price) const;
D.) void addItem(string name[], double price);
A? Pass by const reference? This one I'm not too sure of.