Home > Back-end >  C problem for the great god help me have a look
C problem for the great god help me have a look

Time:10-04

#include
Using STD: : cout;
Using STD: : cin;
Using STD: : endl;
#include
Using STD: : string;
#include
The class Invoice
{
Private:
A string NO;
A string description;
Int count;
Int price;

Public:
Invoice (string, string description, int count, int price);
Void setNOOfGood (string NO1)
{
NO=NO.
}
String getNOOfGood ()
{
Return NO;
}
Void setDescriptionOfGood (string description1)
{
Description=description1;
}
String the getDescription ()
{
Return the description;
}
Void setCount (int count1)
{
If (count1 & lt;=0)
{
Count=0;
cout <"Invalid" & lt; }
The else
The count=count1;
}
Int getCount ()
{
Return the count.
}
Void setPrice (int price1)
{
If (price1 & lt;=0)
{
Price=0;
cout <"Invalid" & lt; }
The else
Price=price1;
}
Int getPrice ()
{
The return price;
}
Int getInvoiceAmount ()
{
Return getCount () * getPrice ();
}
};
Int main ()
{
Invoice Invoice (30, "15", "food", 2);
cout <"NO." & lt; cout <"The description:" & lt; cout <"The count:" & lt; cout <"Price:" & lt; cout <"InvoiceAmount:" & lt; system("pause");
return 0;
}

CodePudding user response:

teach me

CodePudding user response:

Invoice (string, string description, int count, int price);
This didn't realize

CodePudding user response:

From your code analysis, it should not be empty, at least need to initialize a few member variables, such as
Invoice (string, string description, int count, int price) : m_NO (NO) {}
I change the member variables to m_NO here, your original name
there will be a conflict
  • Related