Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include<iostream>
- using namespace std;
- #include <string>
- class CPublication
- {
- public:
- CPublication(int i, int j, string k){ page = i; price = j; title = k; };
- void show()
- {
- cout << "page=" << page << endl;
- cout << "price=" << price << endl;
- cout << "title:" << title << endl;
- }
- int getpage(){ return page; }
- int getprice(){ return price; }
- string gettitle(){ return title; }
- private:
- int page, price;
- string title;
- };
- class CBook :public CPublication
- {
- public:
- CBook(int i, int j, string k, string x, string y) :CPublication(i, j, k){ Author = x; ISBN = y; };
- void show()
- {
- cout << "title:" << gettitle() << endl;
- cout << "page=" << getpage() << endl;
- cout << "price=" << getprice() << endl;
- cout << "Author:" << Author << endl;
- cout << "ISBN:" << ISBN << endl;
- }
- private:
- string Author, ISBN;
- };
- void main()
- {
- CBook b1(15, 60, "我是書", "家儀", "DSFDSFSDF");
- CBook b2(50, 600, "我是很貴的書", "家儀", "SDADSFSDF");
- b1.show();
- b2.show();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement