Untitled
unknown
plain_text
2 years ago
677 B
10
Indexable
#include <iostream>
#include <vector>
#include <random>
using namespace std;
class A{
protected:
int a;
public:
A() {
a = 15;
}
};
class B : public A{
int* Ax;
int x;
public:
B(int x) {
this->x = x;
this->Ax = new int[x];
for (int i = 0; i < x; ++i) {
int start = 0;
int end = 30;
int y = rand() % (end - start + 1) + start;
Ax[i] = a * y;
}
}
void Show() {
for (int i = 0; i < x; i++) {
cout << Ax[i] << " ";
}
cout << endl;
}
};
int main() {
B a(5);
a.Show();
}
Editor is loading...