Hello, i posted here a few days ago about a class access issue and have since gotten a new hw to do and did it but i cant get it to run. here is the header and the implementation file so you dont have to ask for it since its hard to explain what my specific problem is.
here is my header file, Invoice.h
Code:
#include <iostream>
#include <string>
using namespace std;
class Invoice
{
private:
string PartNumber;
string PartDescription;
int Quantity;
int PricePerItem;
public:
void setPartNumber(string);
string getPartNumber();
void setPartDescription(string);
string getPartDescription();
void setQuantity(int);
int getQuantity();
void setPricePerItem(int);
int getPricePerItem();
int getInvoiceAmount();
Invoice(string, string, int, int);
};
and my Invoice.cpp
Code:
#include "stdafx.h"
#include "Invoice.h"
#include <string>
using namespace std;
Invoice::Invoice(string num, string description, int quantity, int cost)
{
if(quantity < 0)
{
cout << "Quantity cannot be negative!" << endl;
cout << "Enter new quantity:";
cin >> quantity;
}
if(cost < 0)
{
cout << "PricePerItem cannot be negative!" << endl;
cout << "Enter new price:";
cin >> cost;
}
Invoice::setPartNumber(num);
Invoice::setPartDescription(description);
Invoice::setQuantity(quantity);
Invoice::setPricePerItem(cost);
}
void Invoice::setPartNumber(string num)
{
Invoice::PartNumber = num;
}
string Invoice::getPartNumber()
{
return PartNumber;
}
void Invoice::setPartDescription(string description)
{
PartDescription = description;
}
string Invoice::getPartDescription()
{
return PartDescription;
}
void Invoice::setQuantity(int quantity)
{
Quantity = quantity;
}
int Invoice::getQuantity()
{
return Quantity;
}
void Invoice::setPricePerItem(int cost)
{
PricePerItem = cost;
}
int Invoice::getPricePerItem()
{
return PricePerItem;
}
int getInvoiceAmount()
{
int num = Invoice::getQuantity();
int price = Invoice::getPricePerItem();
int Invoice_Amount = num * price;
return Invoice_Amount;
}
the last part that is bolded is where the compiler keeps telling me the identifier for getQuantity() and getPricePerItem() cannot be found but i have declared them and all that stuff just before it. Can anyone help me out please? i did this exact same thing last time and it worked in a different but similar project and i dont see anything different here except that i am using more than one variables in my constructor than last time...not really sure if thats the problem...feeling kinda lost :/
thanks in advance.