public member cannot be accessed in functions
Posted: Tue Aug 03, 2004 12:43 pm
Hello every one,
I presently have a struct with all kinds of information (bool, char*...) in the public of MyClass (main class). I have a function which loads the information which is called in the constructor of MyClass. When I access the information of the struct in the constructor, every thing is loaded correctly and I can access them. When I try to access the same information from a function there is access violation and 0x024... referenced at 0x927, memory could not be read problems. To trick the computer, I re-loaded the information calling the loading function in the function where I needed it. In that case, the information is loaded correctly but when I want to use it, it crashes!!! It could be a problem of memory which is used the first time and then new things are written over it or something like that but I don't know how to check that and I don't really assign any space anywhere and the free are always used...Help!!
Code snipet:
MyClass.h
struct Pers
bool t;
char* n;
MyClass.cpp
constructor
LoadInfo();
Pers.t; //works
Pers.n; //works
functions
foo()
Pers.t; //doesn't work!!!
Thanx
I presently have a struct with all kinds of information (bool, char*...) in the public of MyClass (main class). I have a function which loads the information which is called in the constructor of MyClass. When I access the information of the struct in the constructor, every thing is loaded correctly and I can access them. When I try to access the same information from a function there is access violation and 0x024... referenced at 0x927, memory could not be read problems. To trick the computer, I re-loaded the information calling the loading function in the function where I needed it. In that case, the information is loaded correctly but when I want to use it, it crashes!!! It could be a problem of memory which is used the first time and then new things are written over it or something like that but I don't know how to check that and I don't really assign any space anywhere and the free are always used...Help!!
Code snipet:
MyClass.h
struct Pers
bool t;
char* n;
MyClass.cpp
constructor
LoadInfo();
Pers.t; //works
Pers.n; //works
functions
foo()
Pers.t; //doesn't work!!!
Thanx