| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 349 人关注过本帖
标题:程序运行出错,不知道怎么改!?
只看楼主 加入收藏
xielei0806
Rank: 2
等 级:论坛游民
帖 子:36
专家分:28
注 册:2012-3-20
结帖率:80%
收藏
已结贴  问题点数:12 回复次数:1 
程序运行出错,不知道怎么改!?
#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
搜索更多相关主题的帖子: public include private void 
2012-12-18 10:02
yuccn
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:何方
等 级:版主
威 望:167
帖 子:6815
专家分:42393
注 册:2010-12-16
收藏
得分:12 
Invoice iv1(1314,"yifu",5,184);
     Invoice iv2(520,"xiezi",4,285);

====》》  

    Invoice iv1("1314","yifu",5,184);
    Invoice iv2("520","xiezi",4,285);

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2012-12-18 11:18
快速回复:程序运行出错,不知道怎么改!?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026484 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved