Array class in C++: How to use one method in another
<p>I have a class for performing various array operations. I like to use my insert method in my populate method.
Can someone guide me on that? Here is the code:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
using namespace std;

const int MAX=5;

class array
{
private:
    int arr[MAX];

public:
    void insert(int pos, int num);
    void populate(int[]);
    void del(int pos);
    void reverse();
    void display();
    void search(int num);
};

void array::populate(int a[])
{
    for (int i=0;i&lt;MAX;i++)
    {
        arr[i]=a[i];
    }
}

void array::insert(int pos, int num)
{
    for (int i=MAX-1;i&gt;=pos;i--)
    {
         arr[i] = arr[i-1];
         arr[i]=num;
    }
}


void array::del(int pos)
{
    for (int i=pos;i&lt;MAX;i++)
    {
        arr[pos]=arr[pos + 1];
    }
}

void array::display()
{
    for (int i=0;i&lt;MAX;i++)
        cout&lt;&lt;arr[i];
}


void array::search(int num)
{
    for (int i=0;i&lt;MAX;i++)
    {
        if (arr[i]==num)
        {
            cout&lt;&lt;"\n"&lt;&lt;num&lt;&lt;" found at index "&lt;&lt;i;
            break;
        }
        if (i==MAX)
        {
            cout&lt;&lt;num &lt;&lt;" does not exist!";
        }
    }
}

int main()
{
    array a;

    for (int j=0;j&lt;MAX;j++)
    {
        a.insert(j,j);
    }

    a.populate(a);

    a.insert(2,7);

    a.display();

    a.search(44);

    system("pause");
}
</code></pre>
