标题:哪里错了,求大神
取消只看楼主
l991160619
Rank: 1
等 级:新手上路
帖 子:4
专家分:7
注 册:2013-9-2
结帖率:0
已结贴  问题点数:20 回复次数:1 
哪里错了,求大神
#include <iostream>
using namespace std;
class cCurrency
{
public:
    cCurrency(float fAmerican,float fEurope);
    virtual void Print_Exchange(){}
    void set();
protected:
    float fAmerican;
    float fEurope;
};

cCurrency::cCurrency(float fAmerican,float fEurope)
{
    this->fAmerican=fAmerican;
    this->fEurope=fEurope;
}

class cAmerican:public cCurrency
{
public:
    void Print_Exchange();
private:
    float RMB;
};
class cEurope:public cCurrency
{
public:
    void Print_Exchange();
private:
    float RMB;
};
void cAmerican::Print_Exchange()
{
    this->RMB=100*fAmerican;
    cout<<this->RMB<<endl;
}

void cEurope::Print_Exchange()
{
    this->RMB=100*fEurope;
    cout<<this->RMB<<endl;
}

void cCurrency::set()
{
    this->fAmerican=(float)6.3492;
    this->fEurope=(float)7.9365;
}

int main()
{
    cCurrency *pCurrency=new cCurrency(2,3);
    cAmerican A1;
    cEurope A2;
    pCurrency=&A1;
    pCurrency->set();
    pCurrency->Print_Exchange();
    pCurrency=&A2;
    pCurrency->set();
    pCurrency->Print_Exchange();
    system("pause");
    return 0;
}
搜索更多相关主题的帖子: private include public 
2013-09-02 17:28
l991160619
Rank: 1
等 级:新手上路
帖 子:4
专家分:7
注 册:2013-9-2
得分:0 
回复 2楼 peach5460
你有本事,你改
2013-09-02 17:46



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-419990-1-1.html




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

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