Advertisement
malixds_

govniwe

Apr 22nd, 2022
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #ifndef Base_h
  2. #define Base_h
  3. #include <iostream>
  4. class Base
  5. {
  6. public:
  7.     int size;
  8.     int* arr;
  9.     void virtual in_out();
  10. };
  11.  
  12. #endif Base_h
  13.  
  14. #include "Base.h"
  15. #include <iostream>
  16. using namespace std;
  17. void Base::in_out (){
  18.     cin >> size;
  19.     arr = new int[size];
  20.     for (int i = 0; i < size; i++)
  21.         cin >> arr[i];
  22. }
  23.  
  24. #ifndef Class1_h
  25. #define Class1_h
  26. #include "Base.h"
  27. #include <iostream>
  28. class Class1 :public Base
  29. {
  30. public:
  31.     virtual int func();
  32. };
  33. #endif
  34.  
  35. #include "Class1.h"
  36. using namespace std;
  37. int Class1 :: func() {
  38.     int x = arr[0];
  39.     for (int i = 1; i < size + 1; i++) {
  40.         x -= arr[i];
  41.     }
  42.     cout << endl << x << endl;
  43.     return x;
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement