Click here to Skip to main content
15,912,457 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: dynamic allocation of arrays Pin
Sauce!30-Sep-08 0:55
Sauce!30-Sep-08 0:55 
GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 1:25
Iain Clarke, Warrior Programmer30-Sep-08 1:25 
GeneralRe: dynamic allocation of arrays Pin
Sauce!30-Sep-08 1:34
Sauce!30-Sep-08 1:34 
GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 1:48
Iain Clarke, Warrior Programmer30-Sep-08 1:48 
GeneralRe: dynamic allocation of arrays Pin
Sauce!30-Sep-08 2:16
Sauce!30-Sep-08 2:16 
GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 3:21
Iain Clarke, Warrior Programmer30-Sep-08 3:21 
GeneralRe: dynamic allocation of arrays [modified] Pin
Sauce!30-Sep-08 5:01
Sauce!30-Sep-08 5:01 
GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 5:31
Iain Clarke, Warrior Programmer30-Sep-08 5:31 
Sauce! wrote:
My tile class certainly isn't that large... (half a terabyte if my calculations are correct!)


OMG | :OMG: OMG | :OMG: OMG | :OMG: OMG | :OMG: OMG | :OMG: OMG | :OMG:

OK, I in no way suspected that the tile class was HUMUNGOUS. And I also find myself a lot skeptical about half a terabyte. That fills half of my biggest harddrive, let alone many multiples of my swap file...

If you really meant it about the Tile class ending up being half a terabyte, then your initial problem is probably dead easy:
"The initial new failed, and p_MyTiles ends up being NULL, and so the delete [] chokes on NULL. The loops weren't crashing due to the sizeof problem with dynamic arrays I mentioned earlier".



As for the Block / Tile interaction... You have to pick either Block or Tile to know about the other. You can forward declare Block, and then use pointers or references (same thing really nearasdammit) in the other.

Ie:
class Block;   // forward declare, so the compiler knows "Block" is a valid name.

class Tile
{
   ...
   void SetParentBlock (Block *pBlock);  // only needs to know that Block exists, nothing more.
   ...
};

class Block
{
   ...
   Tile m_Tiles [4]; // needs to know all about Block's size, so needs to see it's full definition.
   ...
};


I hope that clears it up a bit.

Iain.
GeneralRe: dynamic allocation of arrays Pin
Sauce!30-Sep-08 5:43
Sauce!30-Sep-08 5:43 
GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 6:02
Iain Clarke, Warrior Programmer30-Sep-08 6:02 
GeneralRe: dynamic allocation of arrays Pin
Sauce!2-Oct-08 5:05
Sauce!2-Oct-08 5:05 
GeneralRe: dynamic allocation of arrays [modified] Pin
Sauce!4-Oct-08 2:42
Sauce!4-Oct-08 2:42 
GeneralRe: dynamic allocation of arrays Pin
Sauce!4-Oct-08 5:19
Sauce!4-Oct-08 5:19 
GeneralRe: dynamic allocation of arrays [modified] Pin
Sauce!4-Oct-08 5:34
Sauce!4-Oct-08 5:34 
GeneralRe: dynamic allocation of arrays [modified] Pin
Sauce!4-Oct-08 12:53
Sauce!4-Oct-08 12:53 
GeneralRe: dynamic allocation of arrays Pin
Sauce!17-Oct-08 20:58
Sauce!17-Oct-08 20:58 
Questionno WM_MOUSEHOVER in an edit Pin
followait28-Sep-08 18:58
followait28-Sep-08 18:58 
AnswerRe: no WM_MOUSEHOVER in an edit Pin
Iain Clarke, Warrior Programmer30-Sep-08 0:25
Iain Clarke, Warrior Programmer30-Sep-08 0:25 
QuestionCListCtrl Problem Pin
Dhiraj kumar Saini28-Sep-08 18:53
Dhiraj kumar Saini28-Sep-08 18:53 
AnswerRe: CListCtrl Problem Pin
_AnsHUMAN_ 28-Sep-08 18:59
_AnsHUMAN_ 28-Sep-08 18:59 
AnswerRe: CListCtrl Problem Pin
Naveen28-Sep-08 19:01
Naveen28-Sep-08 19:01 
QuestionWrite a buffer to stringstream Pin
CodingLover28-Sep-08 18:43
CodingLover28-Sep-08 18:43 
AnswerRe: Write a buffer to stringstream Pin
Naveen28-Sep-08 19:04
Naveen28-Sep-08 19:04 
GeneralRe: Write a buffer to stringstream Pin
CodingLover28-Sep-08 19:08
CodingLover28-Sep-08 19:08 
GeneralRe: Write a buffer to stringstream Pin
Naveen28-Sep-08 19:26
Naveen28-Sep-08 19:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.