Skip to content

Instantly share code, notes, and snippets.

@amkatrutsa
Created June 28, 2014 11:37
Show Gist options
  • Save amkatrutsa/232593762e00fa82895f to your computer and use it in GitHub Desktop.
Save amkatrutsa/232593762e00fa82895f to your computer and use it in GitHub Desktop.
class MyVector {
int* vector;
int size;
public:
MyVector() : vector(new int[1]), size(1) { }
MyVector(int size) {
vector = new int[size];
this->size = size;
}
MyVector(int size, int num) {
vector = new int[size];
this->size = size;
for (int i = 0; i < size; i++)
vector[i] = num;
}
void push(int num);
void pop();
int getsize();
int operator [] (int index) const {
return this->vector[index];
}
~MyVector() { delete[] vector; delete &size; }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment