Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class first
- {
- protected:
- int *mas;
- int size;
- public:
- first()
- {
- cout << "Size: ";
- cin >> size; cout << endl;
- mas = new int[size];
- cout << "Array: ";
- for (int i = 0; i < size; i++)
- {
- cin >> mas[i];
- cout << " ";
- }
- }
- void sum()
- {
- int sum = 0;
- for (int i = 0; i < size; i++)
- {
- sum += mas[i];
- }
- cout <<"S = " << sum << endl;
- }
- ~first()
- {
- delete[]mas;
- }
- };
- class second : public first
- {
- private:
- first b;
- int mult;
- public:
- second() : b()
- {
- mult = 1;
- }
- void multiply()
- {
- for (int i = 0; i < size; i++)
- {
- mult *= mas[i];
- }
- cout << "M = " << mult << endl;
- }
- };
- int main()
- {
- second a;
- a.sum();
- a.multiply();
- return 0;
- }
Add Comment
Please, Sign In to add comment