Accessing variables...

J

Jurek Dabrowski

hi all,

I have a question in reference to accessing variables in another class maybe
someone has dealt with before.
I have some public variables declared in my main plug-in class
CCommandMeshToSrf,
eg: BOOL m_bHaveAnswer;
I want to set this variable from within a dialog class which is defined in
separate .h and .cpp files of course. How would one access this varibale
from a method defined in my CTestModelessDialog class ?

I had this working in a previous version by declaring a pointer to the main
plug-in
class:
CCommandMeshToSrf *m_cmd; and then accessing the public vairable in the
CTestModelessDialog class by using:

m_cmd->m_bHaveAnswer

Recently, it shows up as an undefined variable and crashes....any ideas
?



thanks,

jurek
 
D

Daniel T.

"Jurek Dabrowski said:
hi all,

I have a question in reference to accessing variables in another class maybe
someone has dealt with before.
I have some public variables declared in my main plug-in class
CCommandMeshToSrf,
eg: BOOL m_bHaveAnswer;
I want to set this variable from within a dialog class which is defined in
separate .h and .cpp files of course. How would one access this varibale
from a method defined in my CTestModelessDialog class ?

I had this working in a previous version by declaring a pointer to the main
plug-in
class:
CCommandMeshToSrf *m_cmd; and then accessing the public vairable in the
CTestModelessDialog class by using:

m_cmd->m_bHaveAnswer

Recently, it shows up as an undefined variable and crashes....any ideas
?

Did you initialize it?
 
J

Jim Langston

Jurek Dabrowski said:
hi all,

I have a question in reference to accessing variables in another class
maybe
someone has dealt with before.
I have some public variables declared in my main plug-in class
CCommandMeshToSrf,
eg: BOOL m_bHaveAnswer;
I want to set this variable from within a dialog class which is defined in
separate .h and .cpp files of course. How would one access this varibale
from a method defined in my CTestModelessDialog class ?

I had this working in a previous version by declaring a pointer to the
main
plug-in
class:
CCommandMeshToSrf *m_cmd; and then accessing the public vairable in the
CTestModelessDialog class by using:

m_cmd->m_bHaveAnswer

Recently, it shows up as an undefined variable and crashes....any ideas
?



thanks,

jurek

"Recently, it shows up as an undefined varaible and crashes..." That is an
oxymoron. If it is an undefined variable, it won't compile. I has to
compile to crash, and if it compiles it's not an undefined variable.

If it fails to compile (link error) then most likely you forgot to include
the header file (.h) in the other .cpp file.

If it crashes, then maybe it's not initialized.

The normal way is to pass a pointer, or better yet, a reference.

Please show code and the actual error/crash if this doesn't help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top