Advertisement
endreweast

Practic 3.1

Dec 17th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class publication
  6. {
  7.    private:
  8.        char name[100];
  9.        float cost;
  10.    public:
  11. void getdata()
  12. {
  13.     cout << "Name book" << endl;
  14.     cin >> name;
  15.     cout << "Cost book" << endl;
  16.     cin >> cost;
  17. }
  18. void putdata()
  19. {
  20.     cout << "Book:" << endl;
  21.     cout << "Name - " << name << endl;
  22.     cout << "Cost - " << cost << " $" << endl;
  23. }
  24. };
  25. class book : public publication
  26. {
  27.    public:
  28.        int tops;
  29.        void gettops()
  30.        {
  31.            cout << "Write tops in the book" << endl;
  32.            cin >> tops;
  33.        }
  34.        void puttops()
  35.        {
  36.            cout << tops << " - Tops" << endl;
  37.        }
  38. };
  39.        class type : public publication
  40.        {
  41.        public:
  42.            float time;
  43.            void gettime()
  44.            {
  45.                cout << "Write time book" << endl;
  46.                cin >> time;
  47.            }
  48.            void puttime()
  49.            {
  50.                cout << "Time - " << time << " hours" << endl;
  51.            }
  52. };
  53. int main()
  54. {
  55.     publication obj;
  56.     book obj1;
  57.     type obj2;
  58.     obj.getdata();
  59.     obj.putdata();
  60.     obj1.gettops();
  61.     obj1.puttops();
  62.     obj2.gettime();
  63.     obj2.puttime();
  64.     system("pause");
  65.     return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement