this is my .cpp file content:
#include <iostream>
#include"1.h"
using namespace std;
Stack:: Stack(){
size=20;
a=new int[size];
top=-1;
}
Stack::Stack (int si){
size=si;
a=new int[si];
top =-1;}
Stack::Stack(Stack& s){
a=new int[s.size];
for(int i=0 ; i<s.size; i++)
a[i]=s.a[i];
size=s.size;
}
Stack::~Stack(){
delete [] a;
}
void Stack::Push(int data){
if(this->isfull())
cout<<"stack is full!\n";
else
a[top++]=data;
}
int Stack::Pop(){
if(this->isempty())
cout<<"stack is empty!\n";
else
return a[top--];
}
bool Stack::isempty(){
if(top==-1)
return true;
else
return false ;
}
bool Stack::isfull(){
if(top==size-1 )
return true ;
else
return false ;
}
void Stack::Print(){
for(int i=top ; i>-1 ; i--)
cout<<a[i]<<endl;
}
int main(){
Stack a(3);
a.Push(1);
a.Push(3);
cout<<a.Pop();
a.Push(5);
a.Push(7);
a.Print();
return 0;
}
And after running the program, i get the following error: Error in `./1': double free or corruption (out): 0x000000000240a010 *** Aborted (core dumped) and I have copy constructor and any thing, what sould I do?