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

  • <center id="usuqs"></center>
  • 
    
  • C++(定義一個(gè)Book(圖書)類)

    C++(定義一個(gè)Book(圖書)類)
    定義一個(gè)Book(圖書)類,在該類定義中包括
    數(shù)據(jù)成員: bookname(書名)、price(價(jià)格)和number(存書數(shù)量);
    成員函數(shù): display()顯示圖書的情況;borrow()將存書數(shù)量減1,并顯示當(dāng)前存書數(shù)量;restore()將存書數(shù)量加1,并顯示當(dāng)前存書數(shù)量.
    在main函數(shù)中,要求創(chuàng)建某一種圖書對象,并對該圖書進(jìn)行簡單的顯示、借閱和歸還管理.
    其他人氣:578 ℃時(shí)間:2020-02-06 01:31:08
    優(yōu)質(zhì)解答
    測試通過(編譯器為gcc-3.4.5):
    #include
    #include
    int main(){
    class Book{
    public:
    long number;
    float price;
    char *bookname;
    void display(){
    printf("The name of this book is:%s\n",bookname);
    printf("The price of this book is:%f
    dolars\n",price);
    printf("The number of such book is:%d\n",number);
    }
    void restore(){
    number++;
    }
    void borrow(){
    number--;
    }
    };
    Book b;
    b.bookname="Harry Potter";
    b.price=18.00;
    b.number=100;
    b.display();
    b.borrow();
    b.display();
    b.restore();
    b.display();
    system("pause");
    return 0;
    }
    我來回答
    類似推薦
    請使用1024x768 IE6.0或更高版本瀏覽器瀏覽本站點(diǎn),以保證最佳閱讀效果。本頁提供作業(yè)小助手,一起搜作業(yè)以及作業(yè)好幫手最新版!
    版權(quán)所有 CopyRight © 2012-2024 作業(yè)小助手 All Rights Reserved. 手機(jī)版