If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

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.

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.