title: How to return an object from a pointer C++
body: <p>I am currently new to coding in C++ and I am having trouble with the pointers. I am making a suduko solver which has a cell class and a cell group class. The cell class has methods which sets the cells value, whether it is an original or given number and multiple methods considering the candidate list (the list of possible numbers the value may be). The <code>CellGroup</code> class has been created so I can have <code>CellGroup</code>s of 9 to check through, for the rows, columns and 3x3 blocks.</p>
  
  <p>I have currently managed to read in the suduko from a file, and populate the cellgroups accordingly. Here is how the cell and the groups are set:</p>
  
  <p>The cell:</p>
  
  <pre><code>Cell::Cell(int value, bool given)
  {
      if (given == true)
      {
          m_given = true;
      }
      else {
          m_given = false;
          for (int i = 1; i &lt; 10; i++) { //1 to 9
              if (i != value) { //if i does not equal the value 
                  m_candidateList.push_back(i);  //populate the candidate list
              }
          }
      }
  }
  </code></pre>
  
  <p>In the cell group class:</p>
  
  <pre><code>void CellGroup::setCell(int index, Cell *cell)
  {
      m_cells[index] = cell;
  }
  </code></pre>
  
  <p>This seems to be working fine when initializing the grid and adding the cells.</p>
  
  <p>My problem at the moment is I am trying to now retrieve these cells, so I can get there values and ultimately try to get a solution.</p>
  
  <p>I have a method in the <code>CellGroup</code> class to retrieve the cell:</p>
  
  <pre><code>Cell* CellGroup::returnCell(int index)
  {
      Cell *cell = m_cells[index];
      return cell;
  }
  </code></pre>
  
  <p>And methods in the cell class to get the value in the cell as well as if the number has been given:</p>
  
  <pre><code>int Cell::getValue(void) const
  {
      return m_value;
  }
  
  bool Cell::getIsGiven(void) const
  {
      if (m_given == true) {
          return true;
      }
      else {
          return false;
      }
  }
  </code></pre>
  
  <p>However in the puzzle class, when I try to retrieve a cells value or whether it has been given or not, it is returning obscure values. I think the pointer is returning an address, and I am unsure on how I can obtain the actual object. Here is what I have currently tried:</p>
  
  <pre><code>void SudokuPuzzle::TryToSolve()
  {
      Cell* cell = m_gridRows[1].returnCell(1);
      Cell newCell = *cell;
      int val = newCell.getValue;
      cout &lt;&lt; val &lt;&lt; endl;
      bool given = newCell.getIsGiven;
      cout &lt;&lt; given &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Apologies if the answer is quite obvious, I am extremely new to C++ and using pointers.</p>
  
  <p>Any advice/solutions would be greatly appreciated!</p>