Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- const int n = 5;
- class A
- {
- protected:
- int mas[n];
- public:
- A()
- {
- cout << "Введите элементы массива: " << endl;
- for (int i = 0; i < n; i++) cin >> mas[i];
- }
- ~A()
- {
- cout << "Деструкто А." << endl;
- }
- };
- class B :public A
- {
- public:
- B() :A() {}
- int operator [] (int n)
- {
- int min = mas[0];
- for (int i = 0; i < n; i++)
- if (mas[i] < min) min = mas[i];
- return min;
- }
- ~B()
- {
- cout << "Деструктор В." << endl;
- }
- };
- int main()
- {
- setlocale(LC_ALL, "Russian");
- B m;
- cout << "Минимальный элемент массива: " << m[n] << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement