Global variable help
-
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 ?
-
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
-
you could try to solve your problem by single/slot mechanism, just connect your login with both .cpp files
@connect(client,SIGNAL(login()),this,SLOT(check4id()));@
-
Could you explain more on how to do this?
-
Which technique ?
-
Hey ..
Check out the following link:http://stackoverflow.com/questions/3627941/global-variable-within-multiple-files
-
Wrong pattern to use in this case.