Help with imple syntax error.
-
But, livesPos is a global variable... And let's assume that 30 and 15 are variables, I'll get some error about not being able to init globals without constant values... :( So how would I do this? Thanks! ;)
Windows Calculator told me I will die at 28. :(
one good way would be to not have globals. Another would be to use a vector. A third would be livesPos = new int[2]; livesPos[0] = 5; livesPos[1] = 666; or whatever.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
one good way would be to not have globals. Another would be to use a vector. A third would be livesPos = new int[2]; livesPos[0] = 5; livesPos[1] = 666; or whatever.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
Christian Graus? You again?! :wtf: I don't think there's ever been a thread by me without you in it... Haha, you do live here, don't you? ;) Anyway, why do people always say not to use globals? I need file "interoperability". :P What should I use then? Thanks! ;)
Windows Calculator told me I will die at 28. :(
-
one good way would be to not have globals. Another would be to use a vector. A third would be livesPos = new int[2]; livesPos[0] = 5; livesPos[1] = 666; or whatever.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
What would you do without global variables?
-
What would you do without global variables?
Well, I would have all my variables available for all my functions without having to pass any annoying parameters... ;P But now I see this doesn't work very well in C... So what should I do, put all of them in main() and pass pointers to my functions? Or how do you do it? Thanks! ;)
Windows Calculator told me I will die at 28. :(
-
Christian Graus? You again?! :wtf: I don't think there's ever been a thread by me without you in it... Haha, you do live here, don't you? ;) Anyway, why do people always say not to use globals? I need file "interoperability". :P What should I use then? Thanks! ;)
Windows Calculator told me I will die at 28. :(
The problem with a global is that you can't debug it, or control it. At a minimum, create a class that has public static methods to get and set variables which are private. That way, you can set breakpoints if you need to debug access to the values. Even better, create a class with protected members, and make the classes you want to grant access, friends of that class.
Lord Kixdemp wrote:
you do live here, don't you?
*grin* 14+ hours a day, yeah.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
What would you do without global variables?
Write maintainable code ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
The problem with a global is that you can't debug it, or control it. At a minimum, create a class that has public static methods to get and set variables which are private. That way, you can set breakpoints if you need to debug access to the values. Even better, create a class with protected members, and make the classes you want to grant access, friends of that class.
Lord Kixdemp wrote:
you do live here, don't you?
*grin* 14+ hours a day, yeah.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
That is all very nice and true only one problem: this guy said he used C and not C++.. I guess u could some OO implementation in C (header represents a class and each function takes a pointer to structure that represents 'this'), still u don't have encapsulation...
-
That is all very nice and true only one problem: this guy said he used C and not C++.. I guess u could some OO implementation in C (header represents a class and each function takes a pointer to structure that represents 'this'), still u don't have encapsulation...
Oh, I missed that. Then, there's no way around it. C kind of sucks that way.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
Write maintainable code ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
Maintainable code? What do you mean? :wtf:
Windows Calculator told me I will die at 28. :(
-
Maintainable code? What do you mean? :wtf:
Windows Calculator told me I will die at 28. :(
It means, code that is easy to work on if you have to come back to it later.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog