title: surprising constructors for a class!
body: <p>What is the problem here in this code? 
  It gives segmentation fault. I found value of size in vector (int *a) 
  is no more 3. How is this?</p>
  
  <pre><code> #include &lt;iostream&gt; 
  
   using namespace std; 
  
   class vector 
   { 
    int *v; 
    int size; 
       public: 
    vector(int m) 
    { 
     v = new int[size = m]; 
     for(int i=0; i&lt;size; i++) 
      v[i] = 0; 
    } 
    vector (int *a) 
    { 
     for(int i=0; i&lt;size; i++) 
      v[i] = a[i]; 
    } 
    int operator*(vector &amp;y) 
    { 
     int sum = 0; 
     for(int i=0; i&lt;size; i++) 
      sum += this -&gt; v[i] * y . v[i]; 
     return sum; 
    }    
   }; 
  
  
   int main() 
   { 
    int x[3] = {1,2,3}; 
    int y[3] = {4,5,6}; 
    vector v1(3); 
    vector v2(3); 
    v1 = x; 
    v2 = y; 
    int R = v1 * v2; 
    cout &lt;&lt; "R = " &lt;&lt; R; 
    return 0; 
   } 
  </code></pre>
  
  <p>Sincerely,<br>
  Srinivas Nayak</p>