Project 2-books and projects of the library-libraries

Source: Internet
Author: User

Project 2-books and projects of the library-libraries

/** Copyright (c) 2014, School of Computer Science, Yantai University * All right reserved. * file name: test. cpp * Author: Zhao yun* completion time: July 15, March 15, 2014 * version: 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 ("miserable world", "Hugo", "Shanghai Foreign Language Education Press", 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 ;}


Running result:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.