title: Deleting dynamic arrays?
body: <p>I'm having problems about deleting dynamic arrays in my project. </p>
  
  <p>First appear: </p>
  
  <pre><code>void StudentReviewSystem::addCourse( const int courseId, const string courseName )
  {
      int i = findCourse( courseId );
  
      if ( i == -1 )
      {
          int newNum = numberOfCourses + 1;
          Course *newCourses = new Course[newNum];
          for ( int j = 0; j &lt; numberOfCourses; j++ )
          {
              newCourses[j] = courses[j];
          }
          Course aCourse(courseId, courseName);
          newCourses[numberOfCourses] = aCourse;
          //delete[] courses;
          courses = newCourses;
          numberOfCourses = newNum;
          cout&lt;&lt; "Course "&lt;&lt; courseId &lt;&lt;" has been added."&lt;&lt; endl;
      }
      else
      {
          cout&lt;&lt; "Course "&lt;&lt; courseId &lt;&lt;" has already exist."&lt;&lt; endl;
      }
  }
  </code></pre>
  
  <p><code>courses</code> is a pointer which was defined in my header.
  If I comment out the <code>delete</code> line, code works just fine, otherwise, program crashes.</p>
  
  <p>Another appear:</p>
  
  <pre><code>StudentReviewSystem::StudentReviewSystem()
  {
      numberOfCourses = 0;
      courses = new Course[0];
  }
  
  StudentReviewSystem::~StudentReviewSystem()
  {
      //delete[] courses;
  }
  </code></pre>
  
  <p>I know I must <code>delete</code> my dynamic arrays to avoid memory leaks, but whenever my destructor is called, program crashes so I comment out that line too. </p>
  
  <p>Whenever I try to delete a dynamic array, program crashes no matter what I do.</p>
  
  <hr>
  
  <p>It turned out that you can't <code>delete[]</code> an array with size 0. So, I check for size every time I want to <code>delete</code> an array. But does a 0 size array causes memory leak?</p>