Ok, what is the meaning of warehouse.
Does it contain a maximum of 10 shelfs, and each shelf maximum of 2 items?
Or vice versa:
Warehouse contains a maximum of 2 shelfs, and each shelf a maximum of 10 items?
What exactly is this:
shelf[10][2]
Am I on the right track here:
Code:
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;
//-------------------------------------------
struct Item
{
Item(const string& name = "", const string& descr = "", const double cost=0) :
sName_(name), sDescription_(descr), dCost_(cost)
{}
//--
string sName_;
string sDescription_;
double dCost_;
};
//-------------------------------------------
class Shelf
{
public:
Shelf() : nQuantity_(0)
{}
~Shelf()
{}
public:
void add_item(const string name, const string descr, const double cost)
{
if(nQuantity_ != 9)
{
theItems[nQuantity_].sName_ = name;
theItems[nQuantity_].sDescription_ = descr;
theItems[nQuantity_].dCost_ = cost;
++nQuantity_;
}
}
private:
unsigned nQuantity_;
//10 items per shelf.
Item theItems[10];
};
//-------------------------------------------
int main()
{
Shelf theShelf;
theShelf.add_item("keyboard", "Nice black Logitech", 50.00);
theShelf.add_item("mouse", "A blue/black MX510", 49.00);
system("PAUSE");
return 0;
}