Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include<iostream>
- #include "MyArray.h"
- using namespace std;
- MyArray::MyArray()
- {
- ptr = new int[size];
- cnt = 0;
- }
- void MyArray::append(int num)
- {
- ptr[cnt++] = num;
- }
- bool MyArray::delete_(int num)
- {
- if(num!=1)
- {
- if(cnt>0)
- {
- cnt--;
- return true;
- }
- else
- return false;
- }
- else
- {
- delete[] ptr;
- ptr=NULL;
- }
- }
- void MyArray::print()
- {
- if(cnt==0)
- cout<<"배열에 값이 비였습니다."<<endl;
- else
- {
- for(int i=0;i<cnt;i++)
- {
- cout<<i+1<<"|"<<ptr[i]<<endl;
- }
- }
- }
Add Comment
Please, Sign In to add comment