MERGING TWO ARRAYS in c++



Merging two arrays
First take two arrays sort them and merge them into third array.

·                     
·                   
#include <iostream.h>
const int SIZE = 10;
class Array
{
private:
int a[SIZE];
int n;
public:
Array()
{
for (int i=0;i<SIZE;i++)
a[i] = 0;
n = 0;
}
void read()
{
int num;
cout<<"how many values you want to enter ? "<<endl;
cin>>num;
for(int i = 0; i<num; i++)
{
cout<<"enter values: "<<endl;
cin>>a[i];
}
n = num;
}
void display()
{
for (int i=0;i<n;i++)
cout << a[i];
cout << endl;
}
void merge(Array a1, Array a2)
{
int i=0,j=0;
while (i< a1.n && j< a2.n )
{
if (a1.a[i] < a2.a[j])
{
a[n] = a1.a[i];
i++;
}
else
{
a[n] = a2.a[j];
j++;
}
n++;

}
while (i < a1.n)
{
a[n] = a1.a[i];
i++; n++;
}
while (j < a2.n)
{
a[n] = a2.a[j];
j++; n++;
}
}
};
void main()
{
Array itm, a2, a3;
itm.read();
itm.display();
cout<<"for 2nd array ";
a2.read();
a2.display();

a3.merge(itm,a2);
a3.display();

}