程序运行出错,不知道怎么改!?
#include<iostream>#include<string>
using namespace std;
class Invoice
{
private:
string PartNumber;
string PartDescribe;
int SellAccount;
int Price;
public:
Invoice(string Pn,string Pd,int Sa,int Pr)
{
PartNumber=Pn;
PartDescribe=Pd;
SellAccount=Sa;
Price=Pr;
if(SellAccount<0){SellAccount=0;}
if(Price<0){Price=0;}
}
int getInvoiceAmount(){return (SellAccount*Price);}
void setPartNumber(string pn){PartNumber=pn;}
void setPartDescribe(string pd){PartDescribe=pd;}
void setSellAccount(int sa)
{
SellAccount=sa;
if(SellAccount<0){SellAccount=0;}
}
void setPrice(int pr)
{
Price=pr;
if(Price<0){Price=0;}
}
string getPartNumber(){return PartNumber;}
string getPartDescribe(){return PartDescribe;}
int getSellAccount(){return SellAccount;}
int getsetPrice(){return Price;}
};
int main()
{
Invoice iv1(1314,"yifu",5,184);
Invoice iv2(520,"xiezi",4,285);
cout<<"The invoice of iv1's message:"<<endl;
cout<<"PartNumber"<<"\t"<<"PartDescribe"<<"\t"<<"SellAccountPrie"<<endl;
cout<<iv1.getPartNumber()<<"\t"<<iv1.getPartDescribe()<<"\t"<<iv1.getSellAccount()<<"\t"<<iv1.getsetPrice()<<"\t"<<iv1.getInvoiceAmount()<<endl;
cout<<"The invoice of iv2's message:"<<endl;
cout<<"PartNumber"<<"\t"<<"PartDescribe"<<"\t"<<"SellAccountPrie"<<endl;
cout<<iv2.getPartNumber()<<"\t"<<iv2.getPartDescribe()<<"\t"<<iv2.getSellAccount()<<"\t"<<iv2.getsetPrice()<<"\t"<<iv2.getInvoiceAmount()<<endl;
return 0;
}
出错:E:\VC6.0兼容win7\Microsoft Visual Studio\MyProjects\123\1.cpp(40) : error C2664: '__thiscall Invoice::Invoice(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_trait
s<char>,class std::allocator<char> >,int,int)' : cannot convert parameter 1 from 'const int' to 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
No constructor could take the source type, or constructor overload resolution was ambiguous
E:\VC6.0兼容win7\Microsoft Visual Studio\MyProjects\123\1.cpp(41) : error C2664: '__thiscall Invoice::Invoice(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_trait
s<char>,class std::allocator<char> >,int,int)' : cannot convert parameter 1 from 'const int' to 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
No constructor could take the source type, or constructor overload resolution was ambiguous