title: Is there a possible memory leak in my C++ file?
body: <p>I'm using an example code given to me by another C++ coder for a project. I'm a new student of C++ language and I wondered is there a possible memory leak / bugs in this class file given to me (PlacementHead.cpp):</p>
  
  <pre><code>#include "PlacementHead.h"
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  #include &lt;string.h&gt;
  
  PlacementHead::PlacementHead(int width, int height, int gap, char* s) {
      width_ = width;
      height_ = height;
      gap_ = gap;
      size_ = (width*height)+1;
      set_ = new char[size_ + 1];
      from_ = new int[size_ + 1];
      original_ = new char[size_ + 1];
      strcpy(set_,s);
      strcpy(original_,s);
  }
  
  PlacementHead::~PlacementHead() {
  
  }
  
  int PlacementHead::getSize() { return size_; }
  int PlacementHead::getHeight() { return height_; }
  int PlacementHead::getWidth() { return width_; }
  int PlacementHead::getGap() { return gap_; }
  
  // Palauttaa indeksissä i olevan suuttimen
  char PlacementHead::getNozzle(int i) {
      return set_[i-1];
  }
  
  // Asettaa indeksissä i olevan suuttimen
  void PlacementHead::setNozzle(int i, char c) {
      set_[i-1] = c;
  }
  
  // Merkitsee suuttimen poimituksi poistamalla sen listasta
  void PlacementHead::markNozzle(int i, int bankPos) {
      set_[i-1] = ' ';
      from_[i-1] = bankPos;
  }
  
  // Palauttaa seuraavan poimimattoman suuttimen indeksin
  int PlacementHead::getNextUnmarkedPos() {
      for (int i=0; i&lt;size_; i++) {
          if (set_[i]!=' ') {
              return i+1;
          }
      }
      return 0;
  }
  
  // Palauttaa suuttimen alkuperäisen sijainnin pankissa
  int PlacementHead::getBankPos(int i) {
      return from_[i-1];
  }
  
  // Plauttaa alkuperäisen ladontapaan suutinjärjestyksen
  void PlacementHead::reset() {
      //for (int i=0; i&lt;size_; i++) {
      //  set_[i] = original_[i];
      //}
      strcpy(set_,original_);
  }
  
  // Tulostusmetodi
  void PlacementHead::print() {
      std::cout &lt;&lt; "ladontapaa:\n";
      for (int h=height_; h&gt;0; h--) {
          for (int w=width_; w&gt;0; w--) {
              int i = ((h-1)*width_)+w;
              std::cout &lt;&lt; getNozzle(i);
          }
          std::cout &lt;&lt; "\n";
      }
  }
  </code></pre>
  
  <p>PlacementHead.h:</p>
  
  <pre><code>#ifndef PLACEMENTHEAD_H
  #define PLACEMENTHEAD_H
  
  class PlacementHead {
      public:
          PlacementHead(int size, int rows, int gap, char* s);
          ~PlacementHead();
          int getSize();
          int getHeight();
          int getWidth();
          int getGap();
          char getNozzle(int i);
          void setNozzle(int i, char c);
          void markNozzle(int i, int bankPos);
          int getNextUnmarkedPos();
          int getBankPos(int i);
          void reset();
          void print();
      private:
          char* set_;
          int* from_;
          char* original_;
          int size_;
          int width_;
          int height_;
          int gap_;
  };
  
  #endif
  </code></pre>
  
  <p>I notice that there is dynamic allocation of memory, but I don't see a <code>delete</code> anywhere...is this a problem? How could I fix this if it is a problem?</p>
  
  <p>Thnx for any help!</p>
  
  <p>P.S.</p>
  
  <p>I noticed there is no keyword <code>class</code> used in this example?...Can you define a class like this?</p>