Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "array.h"
- #include<vector>
- #include<algorithm>
- int Array::objectNumber = 0;
- std::vector<Array*> Array::objects;
- Array::Array(int size)
- {
- values = new int[size];
- objects.push_back(this);
- objectNumber++;
- n = size;
- //to jest tylko zerowanie elementów, nie wiem czy się przyda
- for (int i = 0;i < n;i++) {
- values[i] = 0;
- }
- }
- Array::~Array()
- {
- delete values;
- objectNumber--;
- objects.erase(std::remove(objects.begin(), objects.end(), this), objects.end());
- }
- void Array::inc(int v)
- {
- for (int i = 0; i < objects.size();i++) {
- Array* arr = objects.at(i);
- for (int j = 0;j < arr->n;j++) {
- arr->values[j] += v;
- }
- }
- }
Add Comment
Please, Sign In to add comment