   memory question on pointers
  Say i have a pointer to a class:MyClass *p;If i dont allocate any memory using ''new'' how much memory will be wasted, just the 4bytes? and is it something one should avoid? 
  yup, just the four bytes on the stack. Should you avoid it? Well, not if it serves a purpose.... but what purpose would you use it for?   How appropriate. You fight like a cow. ;  Why bother asking? You should always allocated memory for pointers.   R.I.P. Mark OsbackSolo Pa Mi GenteVG-Force;  You don''t need to allocate memory for pointers if you use them to traverse other memory already allocated.However, it''s good form to always initialize your pointers. Thus, get into the habit of declaring them like so:MyClass * p = 0;For the NULL crowd: the C++ standard says that "0" is the canonical "points nowhere" literal, and NULL is guaranteed to be a synonym. This is different from the C definition of NULL, which is traditionally ((void*)0).;quote:Original post by Sneftel   yup, just the four bytes on the stack. Should you avoid it? Well, not if it serves a purpose.... but what purpose would you use it for?   How appropriate. You fight like a cow.   The porpuse is that I have a two-dimensional array, now only some of its fields need extra information in form of a class. Making a seperate array for these is not good since the class is very dependent on its position in the array. edit: Actually i just decided to copy the position in the array into the extra class.-CProgrammer   [edited by - CProgrammer on September 27, 2003 11:57:08 PM]