精品偷拍一区二区三区,亚洲精品永久 码,亚洲综合日韩精品欧美国产,亚洲国产日韩a在线亚洲

  • <center id="usuqs"></center>
  • 
    
  • C++ see declaration of錯誤 純虛函數(shù)問題

    C++ see declaration of錯誤 純虛函數(shù)問題
    #include
    class vehicle
    {
    protected:
    double weight;
    double vaule;
    public:
    vehicle(double weight,double vaule)
    {
    vehicle::weight=weight;
    vehicle::vaule=vaule;
    }
    virtual double weight()=0;
    virtual double vaule()=0;
    };
    class car:public vehicle
    {
    public:
    car(double weight,double vaule):vehicle(weight,vaule){};
    double weight()
    {
    return weight;
    }
    double vaule()
    {
    return vaule;
    }
    };
    class truck:public vehicle
    {
    public:
    truck(double weight,double vaule):vehicle(weight,vaule){};
    double weight()
    {
    return weight;
    }
    double vaule()
    {
    return vaule;
    }
    };
    class boat:public vehicle
    {
    public:
    boat(double weight,double vaule):vehicle(weight,vaule){};
    double weight()
    {
    return weight;
    }
    double vaule()
    {
    return vaule;
    }
    };
    void main()
    {
    vehicle *p;
    car c1(1000.0,20000.0);
    truck t1(3000.0,100000.0);
    boat b1(9000.0,2000000.0);
    p=&c1;
    cout
    其他人氣:141 ℃時間:2020-05-10 19:13:45
    優(yōu)質(zhì)解答
    程序中變量和函數(shù)用了同樣的名字weight和vaule
    你return weight的時候,編譯器不知道你是要返回變量weight還是返回weight函數(shù)的指針強制轉(zhuǎn)double.
    變量換個名字吧.比如mWeight,mValue
    我來回答
    類似推薦
    請使用1024x768 IE6.0或更高版本瀏覽器瀏覽本站點,以保證最佳閱讀效果。本頁提供作業(yè)小助手,一起搜作業(yè)以及作業(yè)好幫手最新版!
    版權(quán)所有 CopyRight © 2012-2024 作業(yè)小助手 All Rights Reserved. 手機版