B
B Williams
I am stuck on an assignment that uses classes and functions. I am receiving
numerous errors when I try to run a test program to see if I wrote it
correctly. Can someone please point me in the right direction. These are two
of the error messages I am receiving.
error C2660: 'Invoice::setPartNumber' : function does not take 1 arguments
error C3861: 'setItemQuantity': identifier not found
This is the code. Thsnks in advance
#include <string> // class Invoice uses C++ standard string class
using std::string;
// Invoice class definition
class Invoice
{
public:
Invoice( string, string, int, int ); // initializing constructors
void setPartNumber(); // function that sets the part number
string getPartNumber(); // function that gets the part number
void setPartDescription(); // function that sets the part description
string getPartDescription(); // function that gets the part description
void setQuantity(); // function that sets the quantity
int getQuantity(); // function that gets the quantity
void setPrice(); // function that sets the price
int getPrice(); // function that gets the price
int getInvoiceAmount(); // function that calculates the invoice amount
private:
string number;
string description;
int quantity;
int price;
}; // end class Invoice
// Invoice member-function definitions. This file contains
// implementations of the member functions prototyped in 313.h.
#include <iostream>
using std::cout;
using std::endl;
#include "313.h" // include definition of class Invoice
// initializing constructors
Invoice::Invoice( string number, string description, int quantity, int
price )
{
setPartNumber( number ); // call set function to initialize partNumber
setPartDescription( description ); // call set function to initialize
partDescription
setItemQuantity( quantity ); // call set function to initialize quantity
setItemPrice( price ); // call set function to initialize price
} // end Invoice constructors
// function to set the part number
void setPartNumber( string number )
{
partNumber = number; // store the part number in the object
} // end function setPartNumber
// function to get the part number
string getPartNumber()
{
return partNumber; // return object's partNumber
} // end function getPartNumber
// function to set the part description
void setPartDescription( string description )
{
partDescription = description; // store the part description in the
object
} // end function setPartDescription
// function to get the part description
string getPartDescripton()
{
return partDescription; // return object's partDescription
} // end function getPartDescription
// function to set the quantity
void setQuantity( int quantity )
{
itemQuantity = quantity; // store the quantity in the object
} // end function setItemQuantity
// function to get the quantity
int getItemQuantity()
{
return itemQuantity; // return object's Quantity
} // end function getItemQuantity
// function to set the price
void setPrice( int price )
{
itemPrice = price; // store the price in the object
} // end function setItemPrice
// function to get the price
int getItemPrice()
{
return itemPrice; // return object's Price
} // end function getItemPrice
// member function that calculates the invoice amount
int getInvoiceAmount(int quantity, int price)
{
if (quantity < 0)
quantity = 0;
if (price < 0)
price = 0;
InvoiceAmount = (quantity*price);
return InvoiceAmount;
} // end function getInvoiceAmount
// invoice.cpp
// Including class Invoice from 313.h for use in main.
#include <iostream>
using std::cout;
using std::endl;
#include "313.h" // include definition of class Invoice
// function main begins program execution
int main()
{
// create Invoice object
Invoice invoice1( "110-2145", "Chainsaw", 4, 12 );
// display initial value of courseName for each GradeBook
invoice1.getInvoiceAmount();
cout << endl;
return 0; // indicate successful termination
} // end main
numerous errors when I try to run a test program to see if I wrote it
correctly. Can someone please point me in the right direction. These are two
of the error messages I am receiving.
error C2660: 'Invoice::setPartNumber' : function does not take 1 arguments
error C3861: 'setItemQuantity': identifier not found
This is the code. Thsnks in advance
#include <string> // class Invoice uses C++ standard string class
using std::string;
// Invoice class definition
class Invoice
{
public:
Invoice( string, string, int, int ); // initializing constructors
void setPartNumber(); // function that sets the part number
string getPartNumber(); // function that gets the part number
void setPartDescription(); // function that sets the part description
string getPartDescription(); // function that gets the part description
void setQuantity(); // function that sets the quantity
int getQuantity(); // function that gets the quantity
void setPrice(); // function that sets the price
int getPrice(); // function that gets the price
int getInvoiceAmount(); // function that calculates the invoice amount
private:
string number;
string description;
int quantity;
int price;
}; // end class Invoice
// Invoice member-function definitions. This file contains
// implementations of the member functions prototyped in 313.h.
#include <iostream>
using std::cout;
using std::endl;
#include "313.h" // include definition of class Invoice
// initializing constructors
Invoice::Invoice( string number, string description, int quantity, int
price )
{
setPartNumber( number ); // call set function to initialize partNumber
setPartDescription( description ); // call set function to initialize
partDescription
setItemQuantity( quantity ); // call set function to initialize quantity
setItemPrice( price ); // call set function to initialize price
} // end Invoice constructors
// function to set the part number
void setPartNumber( string number )
{
partNumber = number; // store the part number in the object
} // end function setPartNumber
// function to get the part number
string getPartNumber()
{
return partNumber; // return object's partNumber
} // end function getPartNumber
// function to set the part description
void setPartDescription( string description )
{
partDescription = description; // store the part description in the
object
} // end function setPartDescription
// function to get the part description
string getPartDescripton()
{
return partDescription; // return object's partDescription
} // end function getPartDescription
// function to set the quantity
void setQuantity( int quantity )
{
itemQuantity = quantity; // store the quantity in the object
} // end function setItemQuantity
// function to get the quantity
int getItemQuantity()
{
return itemQuantity; // return object's Quantity
} // end function getItemQuantity
// function to set the price
void setPrice( int price )
{
itemPrice = price; // store the price in the object
} // end function setItemPrice
// function to get the price
int getItemPrice()
{
return itemPrice; // return object's Price
} // end function getItemPrice
// member function that calculates the invoice amount
int getInvoiceAmount(int quantity, int price)
{
if (quantity < 0)
quantity = 0;
if (price < 0)
price = 0;
InvoiceAmount = (quantity*price);
return InvoiceAmount;
} // end function getInvoiceAmount
// invoice.cpp
// Including class Invoice from 313.h for use in main.
#include <iostream>
using std::cout;
using std::endl;
#include "313.h" // include definition of class Invoice
// function main begins program execution
int main()
{
// create Invoice object
Invoice invoice1( "110-2145", "Chainsaw", 4, 12 );
// display initial value of courseName for each GradeBook
invoice1.getInvoiceAmount();
cout << endl;
return 0; // indicate successful termination
} // end main