473,770 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing variables...

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
CCommandMeshToS rf,
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 CTestModelessDi alog class ?

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

m_cmd->m_bHaveAnswe r

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

thanks,

jurek


Jan 27 '07 #1
2 2357
In article <32************ ******@newssvr1 2.news.prodigy. net>,
"Jurek Dabrowski" <da*****@sbcglo bal.netwrote:
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
CCommandMeshToS rf,
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 CTestModelessDi alog class ?

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

m_cmd->m_bHaveAnswe r

Recently, it shows up as an undefined variable and crashes....any ideas
?
Did you initialize it?
Jan 27 '07 #2
"Jurek Dabrowski" <da*****@sbcglo bal.netwrote in message
news:32******** **********@news svr12.news.prod igy.net...
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
CCommandMeshToS rf,
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 CTestModelessDi alog class ?

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

m_cmd->m_bHaveAnswe r

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.
Jan 27 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1776
by: Earl Teigrob | last post by:
I am programming ASP.NET using C#. I have been accessing static variables accross my entire application but now need to change some of the static variables that are session specific to instance variables. (For more background, see previous post about 30 min ago) It was so cool using static variables because they where global to the entire application so I could calculate them when the page loaded and use then anywhere in the app. Now...
3
2035
by: Alex | last post by:
I'm having a problem porting an ASP solution to ASPX. In the ASP solution I'm accessing a DCOM server, create sub DCOM objects and call functions from VB script on the ASP pages. The DCOM object handles are stored in session variables. This works fine without a problem. Ported it to ASPX, accessing the same DCOM server from code behind pages. Still, usually no problems. However sometimes I'm seeing an error stating that the DCOM handle...
9
5404
by: Bob Day | last post by:
VS 2003, vb.net , sql msde... I have an application with multiple threads running. Its a telephony application where each thread represents a telephone line. For code that would be the same for each thread, I put in Shared methods as below. It is only now that I am realizing the complexity of multiple threads accessing shared methods. And, quite honestly, I am very confused. I have tried System.Threading.Monitor.Enter, Synclock,...
1
1219
by: Nathan | last post by:
Hi, I have created a class library creating a number of forms and a few public variables. I have a project that references the .dll for this class library, and in that project I need to access those public variables. For instance, the main app calls a form in the referenced library, that form changes the value of PublicVar1 and then closes. The main app now needs to know the value of PublicVar1.
8
2745
by: dwok | last post by:
I have been wondering this for a while now. Suppose I have a class that contains some private member variables. How should I access the variables throughout the class? Should I use properties that expose the variables or is it OK to just access the variables directly? Keep in mind that I am talking about accessing the variables from within the class that they are defined. Thanks!
5
2706
by: Cyril Gupta | last post by:
Hello, I have a class inside another class. The Scenario is like Car->Engine, where Car is a class with a set of properties and methods and Engine is another class inside it with its own set of properties. I want to know if there is a way to access the methods and the properties of the Owner class for the class that's inside it? I.e. I want to find out within Engine what make the Car is which is exposed by the property Car.Model.
5
2478
by: TS | last post by:
is it preferred to access member variables directly in code, on the page that declared them, versus going thru a property accessor? I would think that since theres no security concerns or anything it would be more efficient to access directly. I also don't think that you would need to do any special validation since the class developer knows what the rules are. Note, i am not referring to accessing member variables declared in a...
12
11721
by: Steve Blinkhorn | last post by:
Does anyone know of a way of accessing and modifying variables declared static within a function from outside that function? Please no homilies on why it's bad practice: the context is very particular and involves automatically generated code. I know several other ways of attacking my problem, but this would be the cleanest if it could be made to work. A little more context. I use C as the output of a code generating system which...
6
1635
kaarthikeyapreyan
by: kaarthikeyapreyan | last post by:
Is there any possibility that i could access a the variables that i have defined in a function for example def foo(): i = 10 i = i + 10 I would like to retrieve the value and use it in another function I was able to find a way accessing the variables declared in methods my problem is when i do it with functions and
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10228
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10002
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8883
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7415
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6676
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3575
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.