Page 1 of 1
Uhh help real quick please...
Posted: Tue Sep 01, 2009 10:08 pm
by Bludklok
I might be going crazy but in C++ can't you assign a value to a variable in the global scope?
Code: Select all
int a;
a = 20;
int main()
{
return 0;
}
Either my compiler is being retarded and not letting me do this or I'm losing my mind... or I'm tired.
Re: Uhh help real quick please...
Posted: Tue Sep 01, 2009 10:30 pm
by qpHalcy0n
int a = 20; // This is value assignment and is valid.
int a;
a = 20; // This is an executable piece of code and is NOT valid in the global scope.
Re: Uhh help real quick please...
Posted: Tue Sep 01, 2009 10:40 pm
by Bludklok
qpHalcy0n wrote:int a = 20; // This is value assignment and is valid.
int a;
a = 20; // This is an executable piece of code and is NOT valid in the global scope.
Thought so...
Such a basic rule too. Just been under a lot of stress lately.
Re: Uhh help real quick please...
Posted: Fri Sep 04, 2009 5:16 pm
by RyanPridgeon
qpHalcy0n wrote:int a = 20; // This is value assignment and is valid.
Wow, I never realised you could do that in the global scope
Re: Uhh help real quick please...
Posted: Fri Sep 04, 2009 5:28 pm
by sparda
int a = 20; // This is value assignment and is valid.
assignment != initialization.
That is why you can
initialize:
And not be able to
assign in global scope: