Global variable help
-
wrote on 6 Aug 2014, 17:00 last edited by
I need to make a variable and have it be assessable form all my .cpp files. how do I do this?
Or a way to send a variable to another file so it can be accessed.
-
Hi,
There are several techniques for that but it's generally discourage. Why do you need that global variable ?
-
wrote on 6 Aug 2014, 22:21 last edited by
I have a person login to an account and then I need to detect which account the person logged into, but the account number is on one cpp file and The place I need to check is on another cpp file, so I need to make a way to acsess the variable from both cpp files
-
Then you should rather look after the singleton pattern
-
wrote on 22 Aug 2014, 01:25 last edited by
Could you explain more on how to do this?
-
Which technique ?
-
wrote on 22 Aug 2014, 07:31 last edited by
Hey ..
Check out the following link:http://stackoverflow.com/questions/3627941/global-variable-within-multiple-files
-
Wrong pattern to use in this case.