Median of two array after merge

#include
using namespace std;

class median_merge_array{
public:
int *p;
int size1;
public:
median_merge_array(int s){
p=new int[s];
size1=s;
}
median_merge_array(int s1,int s2){
int s=s1+s2;
p=new int[s];
size1=s1+s2;
}
void get_input_array(){
for(int i=0;i<size1;i++)
cin>>p[i];
}
median_merge_array merge(median_merge_array a2){
int index1=0,index2=0,index=0;
median_merge_array a(size1,size1);

	while(index1<size1 && index2<a2.size1){
		while(p[index1]<=a2.p[index2]){
             a.p[index]=p[index1];
             index++;
             index1++;
		}
		while(p[index1]>=a2.p[index2]){
             a.p[index]=a2.p[index2];
             index++;
             index2++;
		}

	}


	while(index1!=size1){
		     a.p[index]=p[index1];
             index++;
             index1++;
             cout<<index<<" ";
	}
	while(index2!=a2.size1){
		     a.p[index]=a2.p[index2];
             index++;
             index2++;
             cout<<index<<" ";
	}
	return a;
}
int median(){
	if(size1&1==1){
		int mid=size1/2;
		return p[mid];
	}
	else{
		int mid1=size1/2;
		int mid2=mid1+1;
		int med=(p[mid1]+p[mid2])/2;
		return p[med];
	}
}

};

int main(){
int size1;
cin>>size1;

median_merge_array a1(size1);
median_merge_array a2(size1);
median_merge_array a(size1,size1);

a1.get_input_array();
a2.get_input_array();

a=a1.merge(a2);

int med=a.median();
cout<<med<<endl;

return 0;

}

i am try it oop concept but it give run time error

Sample Input 4 1 0 2 9 5 3 4 5 6 7 Sample Output 3, 5, 5, 9, 6, END i did not find out how it output come

In this question, you are given two arrays, arr1[ ] and arr2[ ],
4
1 0 2 9
5
3 4 5 6 7
So you will maintain sum and carry as two variables,
Then you will add the two arrays normally , such that ,you will add normally from right to left.
9+7 =`16, thus carry=1, sum=6
2+6+1 = 9 , sum=9, carry=0
5+0=5 , sum=5, carry=0
4+1=5 , sum=5. carry=0
3
Thus output is : 3, 5, 5, 9, 6

This is explanation for sum of two arrays

Also , the code which you have sent is of different question, so plz tell the exact question along with that send your code by saving on ide only.