-
December 18th, 2012, 02:27 AM
#1
How do access a variable updated in a cpp file to another cpp file?
Hi,
I have two cpp files.I m updating a value of an integer in one cpp file and i want to perform a specific function in the second file as per to the value updated in the first file.
ie
I m initialing the variable in the constructor.
I have two buttons in the first cpp file. On clicking the first button I m updating the variable as 1 and on pressing button two , I m updating the variable as 2.
I m retrieving this variable in the second cpp file with respect to the object created for the class in the first cpp file.
The problem is that i m not able tot retrieve the updated value in the second file. only the initialized value is being retrieved. neither 1 nor 2 is updated.
Thankx a ton in advance.. !!
Regards ,
Sandhya.
-
December 18th, 2012, 08:01 AM
#2
Re: How do access a variable updated in a cpp file to another cpp file?
Originally Posted by sandy2511
Hi,
I have two cpp files.I m updating a value of an integer in one cpp file and i want to perform a specific function in the second file as per to the value updated in the first file.
ie
I m initialing the variable in the constructor.
I have two buttons in the first cpp file. On clicking the first button I m updating the variable as 1 and on pressing button two , I m updating the variable as 2.
I m retrieving this variable in the second cpp file with respect to the object created for the class in the first cpp file.
The problem is that i m not able tot retrieve the updated value in the second file. only the initialized value is being retrieved. neither 1 nor 2 is updated.
Thankx a ton in advance.. !!
Regards ,
Sandhya.
Your question has nothing to do with the Windows API, and honestly has nothing to do with button presses. Also, there are no "cpp files" when you run a program -- you have an executable file that has no idea about what C++ source files were used to create it.
Your question is a C++ language question, more probably dealing with the extern keyword and/or internal/external linkage issues, therefore it should be posted in the Non-Visual C++ forum.
Regards,
Paul McKenzie
-
December 19th, 2012, 04:40 AM
#3
Re: How do access a variable updated in a cpp file to another cpp file?
-
December 19th, 2012, 08:17 AM
#4
Re: How do access a variable updated in a cpp file to another cpp file?
Typically you'd just pass the value as an argument to your function.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|