項目二--圖書館的書,項目--圖書館

來源:互聯網
上載者:User

項目二--圖書館的書,項目--圖書館

/*  *Copyright (c) 2014, 煙台大學電腦學院  * All right reserved.  * 檔案名稱:test.cpp    * 作者:趙嵩  * 完成時間:2014年3月15號  * 版本號碼:v1.0  */ #include <iostream>#include <string>using namespace std;class Book{private:    string name;    string writer;    string public_name;    double price;    int number;    int NO;public:    void setBook(string n,string w,string pu,double pr,int nu,int N);    void borrow();    void restore();    void set_No(int);    int get_No();    void print();};int main(){    Book book;    book.setBook("悲慘世界","雨果","上海外語教育出版社",45,23,1234);    book.print();    book.borrow();    book.print();    book.restore();    book.print();    book.set_No(4321);    book.print();    return 0;}void Book::setBook(string n,string w,string pu,double pr,int nu,int N){    name=n;    writer=w;    public_name=pu;    price=pr;    number=nu;    NO=N;}void Book::borrow(){    number--;}void Book::restore(){    number++;}void Book::set_No(int n1){    NO=n1;}int Book::get_No(){    return NO;}void Book::print(){    cout<<"name:"<<name<<endl;    cout<<"writer:"<<writer<<endl;    cout<<"public_name:"<<public_name<<endl;    cout<<"price:"<<price<<endl;    cout<<"number:"<<number<<endl;    cout<<"NO:"<<NO<<endl<<endl;}


運行結果:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.