IntSetArray implementation in c++
<p>i have trying to imlement  IntSetArray  in c++ it compiles fine but result is wrong  first 300 is ok and other numbers are below zero  something very strange numbers .e.g  -8231313  something like this)
 what is wrong? it is code</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;
int quantity=10;
class  Set
{
private :
    int n,*x;
public:
    Set(int maxval){
        x=new int[quantity+1];
        n=0;
        x[0]=maxval;

    }
    int size(){ return n;}
    void insert(int t){

         for (int i=0;x[i]&lt;t;i++)
         {

              if (x[i]==t)
                   return ;
               for (int j=n;j&gt;=i;j--)
                   x[j+1]=x[j];
               x[i]=t;
         }

               n++;




    }

     void display()
     {
           for (int i=0;i&lt;n;i++){
               cout&lt;&lt;x[i]&lt;&lt;"  "&lt;&lt;"\n";
           }
     }



};

int main(){

    Set s(300);
    s.insert(123);
    s.insert(45);
    s.insert(89);
    s.insert(50);
    s.insert(13);
    s.insert(19);
    s.display();

     return 0;
}
</code></pre>
