Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class cs{
- public:
- int size;
- int*array;
- int index;
- cs(){
- array = new int[10];
- size = 10;
- index = 0;
- }
- ~cs(){
- delete[] array;
- }
- void append(int n){
- if (index == size){
- int * new_arr = new int[size + 10];
- for(int i = 0; i < size; i++){
- new_arr[i] = array[i];
- }
- delete [] array;
- array = new_arr;
- size = size + 10;
- }
- array[index] = n;
- index = index + 1;
- }
- void print(){
- for (int i = 0; i < index; i++){
- cout<< array[i]<< endl;
- }
- }
- };
- int main()
- {
- cs b = cs();
- for (int i = 0; i < 55; i++){
- b.append(i);
- }
- b.print();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement