can anyone please tell me what's wrong with my code?
I have made this code but the compiler is giving the error that all member functions are non-class type. I can't fix this. Here is my code:
#include<iostream>
#include<string>
using namespace std;
/*class Invoice which demonstrates capabilties
*/
class invoice
{
private:
string part_num;
string part_desc;
int quantity;
int price;
public:
invoice(string p_n, string p_d, int q, int p) //constructor
{
part_num=p_n;
part_desc=p_d;
quantity=q;
price=p;
}
void setpart_num(string number) //set function for part_num
{
part_num=number;
}
string getpart_num()
{
return part_num;
}
void setpart_desc(string description) //set function for part_desc
{
part_desc=description;
}
string getpart_desc()
{
return part_desc;
}
void setquantity(int quant) //set function for quantity
{
if(quant>0)
quantity=quant;
else
quantity=0;
}
int getquantity()
{
return quantity;
}
void setprice(int pr) //set function for price
{
if(pr>0)
price=pr;
else
price=0;
}
int getprice()
{
return price;
}
int GetInvoiceAmmount()
{
return quantity*price;
}
};
/*main body
*/
int main()
{
invoice In();
string number;
string description;
int quant, pr,ans;
cout<<"enter part number"<<endl;
getline(cin,number);
cout<<"enter part description"<<endl;
getline(cin,description);
cout<<"enter the quantity of stated part"<<endl;
cin>>quant;
cout<<"enter price"<<endl;
cin>>pr;
In.setpart_num(number);
In.getpart_num();
In.setpart_desc(description);
In.getpart_desc();
In.setquantity(quant);
In.getquantity();
In.setprice(pr);
In.getprice();
ans=In.GetInvoiceAmmount();
cout<<"invoice ammount is: "<<ans;
return 0;
}