title: How to make all array elements accessible
body: <p>I've been trying to make the elements of an array accessible, but I've had no success so far. This is the code, and I've created it due to the given assignment. </p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;iomanip&gt;
  #include&lt;cmath&gt;
  using namespace std;
  
  class Matrix_1D
  {
  private:
      int *p2values;
      int num_elements;
  public:
      Matrix_1D(int *p2v, int n); // CTOR
      ~Matrix_1D(); // DTOR
      void show();
  };
  
  Matrix_1D::Matrix_1D(int *p2v, int n)
  {
      n = sizeof(p2v)/sizeof(int); // the problem comes from the fact that sizeof(p2v) = 4 bytes, and not the length of the entire array!!!
      num_elements = n;
      p2values = new int [n];
      for(int i = 0; i&lt;num_elements; i++)
          p2values[i] = p2v[i];
  }
  
  Matrix_1D::~Matrix_1D()
  {
      delete [] p2values;
  }
  
  void Matrix_1D::show()
  {
      for(int i=0; i&lt;num_elements; i++)
          cout &lt;&lt; p2values[i] &lt;&lt; endl;
  }
  
  int main()
  {
      int array_a[] = {5,3,5};
  
      Matrix_1D fkt_1D_a(array_a, sizeof(array_a)/sizeof(int));
  
      fkt_1D_a.show();
  
      system("pause");
      return 0;
  }
  </code></pre>