Allocating memory problem
Ok - I have a special structure in my program which holds an array of chars. I then have a class that has one of these structs, and when the class is initialized, so is the array of chars. When I debug the program, the char array in the structure is allocated, and does acutally store values to it, but then when I try to use the structures array, it crashes because it can''t find a value in the array, even though it has been allocated. Anyone know what the problem could be?
Code?
edit:
Struct with array in class.
[edited by - honayboyz on June 3, 2003 8:55:46 PM]
edit:
Struct with array in class.
struct sChars{ char *array; sChars(){array = new char[5];} ~sChars(){delete[] array;}};class cMyclass{public: sChars *myarray; cMyclass(){myarray = new sChars();} ~cMyclass(){delete myarray;}};
[edited by - honayboyz on June 3, 2003 8:55:46 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement