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