T
tugnutt7
Ok so basically my spec file is set up as follows:
#ifndef INVENTORY
#define INVENTORY
#include <string>
using namespace std;
struct Product
{
int prodCode;
string description;
double price;
};
class Inventory
{
private:
Product items[25];
int maxItems;
int curNoProd;
int findProduct(int /*Product Code*/);
public:
Inventory(string /*File Name*/, int /*Max Items*/);
void addProduct(int /*Product Code*/, string /*Description*/,
double /*Price*/);
void displayProduct(int /*Product Code*/);
void writeToFile(ofstream&);
bool isArrayFull(){return (curNoProd == maxItems);};
int getCurrentNoElems() const {return curNoProd;};
void increasePrice(int /*Product Code*/, double /*Price
Increase*/);
};
#endif
Now in my implementation file i have most of the function defined
however my problem occurs when trying to define my addProduct and
increasePrice functions. Currently i have this:
void Inventory::addProduct(int newProductCode, string newDescription,
double newPrice)
{
if (newPrice <= 0 || newPrice > 50)
cout<<"Price is out of range, must be greater than 0, with a
max of 50"<<endl;
else if (newProductCode < 10000 || newProductCode > 99999)
cout<<"Product code must be a 5 digit number."<<endl;
else
{
int location = findProduct(newProductCode);
if (location != curNoProd)
cout<<"Product "<<newProductCode<<" already
exists."<<endl;
else if (isArrayFull())
cout<<"No more room for items, current max is
"<<maxItems<<endl;
else
{
items.prodCode[location] = newProductCode;
items.description[location] = newDescription;
items.price[location] = newPrice;
curNoProd++;
}
}
}
I am getting three errors on for each of my assignment statements.
request for member `prodCode' in `((Inventory*)this)-
which is of non-class type `Product[25]'
those are my errors and i cannot figure out why these errors are
occuring.
#ifndef INVENTORY
#define INVENTORY
#include <string>
using namespace std;
struct Product
{
int prodCode;
string description;
double price;
};
class Inventory
{
private:
Product items[25];
int maxItems;
int curNoProd;
int findProduct(int /*Product Code*/);
public:
Inventory(string /*File Name*/, int /*Max Items*/);
void addProduct(int /*Product Code*/, string /*Description*/,
double /*Price*/);
void displayProduct(int /*Product Code*/);
void writeToFile(ofstream&);
bool isArrayFull(){return (curNoProd == maxItems);};
int getCurrentNoElems() const {return curNoProd;};
void increasePrice(int /*Product Code*/, double /*Price
Increase*/);
};
#endif
Now in my implementation file i have most of the function defined
however my problem occurs when trying to define my addProduct and
increasePrice functions. Currently i have this:
void Inventory::addProduct(int newProductCode, string newDescription,
double newPrice)
{
if (newPrice <= 0 || newPrice > 50)
cout<<"Price is out of range, must be greater than 0, with a
max of 50"<<endl;
else if (newProductCode < 10000 || newProductCode > 99999)
cout<<"Product code must be a 5 digit number."<<endl;
else
{
int location = findProduct(newProductCode);
if (location != curNoProd)
cout<<"Product "<<newProductCode<<" already
exists."<<endl;
else if (isArrayFull())
cout<<"No more room for items, current max is
"<<maxItems<<endl;
else
{
items.prodCode[location] = newProductCode;
items.description[location] = newDescription;
items.price[location] = newPrice;
curNoProd++;
}
}
}
I am getting three errors on for each of my assignment statements.
request for member `prodCode' in `((Inventory*)this)-
request for member `description' in `((Inventory*)this)-Inventory::items', which is of non-class type `Product[25]'
request for member `price' in `((Inventory*)this)->Inventory::items',Inventory::items', which is of non-class type `Product[25]'
which is of non-class type `Product[25]'
those are my errors and i cannot figure out why these errors are
occuring.