[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Newbie question: The correct way to delete a pointer array to a poin
From: |
Paul Pluzhnikov |
Subject: |
Re: Newbie question: The correct way to delete a pointer array to a pointer array |
Date: |
25 Feb 2005 13:16:28 -0800 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence) |
Thomas <tlann@technoeclectic.com> writes:
> What is the correct way for me to call delete?
for (int x=0; x < m_iWidth; x++)
delete [] m_pcPuzzle[x];
delete [] m_pcPuzzle;
> Am I allocating the memory correctly?
Yes, assuming you want to use x[i][j] syntax to access it.
However, since you are coding in C++ there are more efficient (and
less error-prone) ways to implement this, while still preserving the
"double index" syntax.
Think "class Puzzle { char *operator[](int); ...};"
Oh, and I drop that horrible Hungarian naming convention, would
you ...
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Newbie question: The correct way to delete a pointer array to a pointer array,
Paul Pluzhnikov <=