Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Accessing variables...

Reply
Thread Tools

Accessing variables...

 
 
Jurek Dabrowski
Guest
Posts: n/a
 
      01-27-2007
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




 
Reply With Quote
 
 
 
 
Daniel T.
Guest
Posts: n/a
 
      01-27-2007
In article <32Nuh.13932$(E-Mail Removed) >,
"Jurek Dabrowski" <(E-Mail Removed)> wrote:

> 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?
 
Reply With Quote
 
 
 
 
Jim Langston
Guest
Posts: n/a
 
      01-27-2007
"Jurek Dabrowski" <(E-Mail Removed)> wrote in message
news:32Nuh.13932$(E-Mail Removed) et...
> 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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Who is accessing my WLAN? =?Utf-8?B?SmFtZXM=?= Wireless Networking 4 03-01-2005 05:09 PM
accessing other computer via wireless =?Utf-8?B?Sm9zaDE1OQ==?= Wireless Networking 1 09-21-2004 10:06 PM
Re: Accessing applications on each computer using wireless networking Pavel A. Wireless Networking 1 09-15-2004 01:55 PM
Re: Accessing applications on each computer using wireless networking Jeff Durham Wireless Networking 0 09-15-2004 02:18 AM
RE: Accessing applications on each computer using wireless networking =?Utf-8?B?bW8=?= Wireless Networking 0 09-14-2004 10:27 PM



Advertisments