geicogeko
|
  |
| Joined: 27 Apr 2010 |
| Total Posts: 2727 |
|
|
| 07 Jun 2012 10:52 AM |
I assign a global variable in one function, I output it and it is correct, I output that variable in another function and it is one, I am going to guess I'm just stupid. /rqF7E2rV
[::Legal Lizard::] |
|
|
| Report Abuse |
|
|
|
| 07 Jun 2012 10:56 AM |
> 2012 > Global variables in c++ |
|
|
| Report Abuse |
|
|
geicogeko
|
  |
| Joined: 27 Apr 2010 |
| Total Posts: 2727 |
|
|
| 07 Jun 2012 11:04 AM |
Pardon my stupidity.
[::Legal Lizard::] |
|
|
| Report Abuse |
|
|
geicogeko
|
  |
| Joined: 27 Apr 2010 |
| Total Posts: 2727 |
|
|
| 07 Jun 2012 11:07 AM |
I'm sure I am just missing something.
[::Legal Lizard::] |
|
|
| Report Abuse |
|
|
| |
|
su8
|
  |
| Joined: 06 Mar 2009 |
| Total Posts: 6334 |
|
|
| 07 Jun 2012 11:12 AM |
>1. Why not use the entire std namespace
Why use entire std when you're only going to use cout and cin? |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 07 Jun 2012 11:16 AM |
| `if ((choice = 1) || (choice = 2))` is the cause of your problem. That assigns 1 to `choice`, which evaluates to true, which prevents C++ evaluating the next expression in the if (since `true || x` is always true). That is why `choice` is always 1. |
|
|
| Report Abuse |
|
|
geicogeko
|
  |
| Joined: 27 Apr 2010 |
| Total Posts: 2727 |
|
|
| 07 Jun 2012 11:21 AM |
Wow, derp derp derp. Trust me, I can code even worse, my last attempt at this would have left you wishing to has a spoon with which you could remove your eyes.
[::Legal Lizard::] |
|
|
| Report Abuse |
|
|
Legend26
|
  |
| Joined: 08 Sep 2008 |
| Total Posts: 10586 |
|
|
| 07 Jun 2012 11:48 AM |
Heh. Well I did spend hours on a LNK2019 error the other day...
Turned out that it wasn't the code, but some obscure VS problem and all I had to do was recreate the file with the same code. |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 07 Jun 2012 11:53 AM |
| I google my C++ errors that I do not recognize so I get a good idea of what is causing problems. |
|
|
| Report Abuse |
|
|