I've created these two classes and I have to display the information that is in the first class. I am unsure as how to do this since it is contained in the private part of the class. I want to go and display the cPRODUCT's private info in the cINVENTORY class's addProduct() method.
Code:
#include <iostream>
#include <string>
using namespace std;
class cPRODUCT
{
private:
long nSerialNum;
string ProductDesc;
float fWholesale;
float fRetailcost;
int nInStock;
public:
cPRODUCT(void)
{
nSerialNum = 0;
ProductDesc = "";
fWholesale = 0;
fRetailcost = 0;
nInStock = 0;
}
void enterProdInfo(void)
{
const int MINIMUM_SERIAL_NUMBER = 100000;
const int MAXIMUM_SERIAL_NUMBER = 999999;
cout << "Please enter the product's six digit serial number: ";
cin >> nSerialNum;
cout << "Please enter the product description: ";
cin >> ProductDesc;
cout << "Please enter the wholesale price: ";
cin >> fWholesale;
cout << "Please enter an appropriate amount: ";
cin >> fWholesale;
}
cout << "Please enter the number of items in stock: ";
cin >> nInStock;
}
float calcRetail(void)
{
return fRetailcost;
}
void displayProd(void)
{
cout << ProductDesc;
}
float getWholesale(void)
{
return fWholesale;
}
int getInStock(void)
{
return nInStock;
}
bool isExpensive(void)
{
}
};
Code:
#include <iostream>
#include <string>
using namespace std;
class cINVENTORY
{
private:
cPRODUCT Products[100];
short nNumProdTypes;
float fTotalWhole;
float fTotalRetail;
int nOverallItems;
public:
cINVENTORY(void)
{
Products[100];
nNumProdTypes = 0;
fTotalWhole = 0;
fTotalRetail = 0;
nOverallItems = 0;
}
void addProduct(int* i, float* fTotalWhole)
{
float fWholesaleCost = 0;
//Fill the Products array
Products[*i].enterProdInfo();
nNumProdTypes++;
//Do Calculations (Total Wholesale, Retail, and InStock)
fWholesaleCost = Products[*i].getWholesale();
*fTotalWhole += fWholesaleCost;
}
void resetInventory()
{
}
void displayInventory(int* i)
{
}
};
I really appreciate any help you guys can give.
Thanks,
...Dan