To add another reason, globals don't go out of scope. They are not destroyed. They exist across the entire code and during the entire lenght of the program. Your program, if of medium size, will probably exhaust all its available memory.
To add another reason, globals don't go out of scope. They are not destroyed. They exist across the entire code and during the entire lenght of the program. Your program, if of medium size, will probably exhaust all its available memory.
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
That hits too close to home! (Job hazard -- but an underestimate to the number of lines of code.)Originally Posted by swgh
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
regular expressions. pray tell your editor has it or you have some external tool
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
Ok, I'll try to stay away from using globals as much as possible . Sorry for all the stupid questions, and thanks alot for answering them. I just got a book on C++ yesterday and havent put it down since lol. So Im just startin out, but I want to learn to program efficiently now, and Im hoping these forums will help me do that. Thanks alot!
[Heading a bit off-topic...]I'm stuck with CodeWright right now (and the vendor IDE which are both okay), but fighting for SlickEdit which both do -- but there's a twist: half of it is still in assembly, so sometimes the names don't match their C names. And some assembly macros for variable definitions (some not). It's fun (not).Originally Posted by Mario F.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
Ok, here is some advice.
# learn as much C++ as you can
# code till your eyes fall out
# do not switch to game programmng books untill you are ok in using the following topics:
*classes ( very important in game programming )
*functions
*pointers ( important )
*references
*arrays - including vectors, iterators, algorithms ( used for sorting )
*memory managment, the use of new and delete keywords
*debugging - using throw and catch exceptions
*code maintence
It seems alot, and it is. You have to have at the very minimum a breif understanding of most if not all the above before I would consider game progamming books. If you learn the above, and are confident in the use of it ( this takes time - but also great fun ) you will have taken a great step to learning some of the most important issues in game programming. A good book(s) help to, a few I recomend are: C++, how to program 5th edition and beginning C++ game programming by Micheal morrison.
Finally, good luck -- if you need any advise, come on the boards and we are happy to help
I accidently deleted this post.... lol ya Im pretty dumb, anyways, Im gonna repost it so it doesnt look like the guy that replied(thank you!) didnt make sense, and incase someone else wants to reply. Sorry =/
Ive got 1 more question, and I dont think its worth makin a whole new thread, so I'll just post it here. Im 16 years old, 17 in 3 months, and I plan on getting a degree in computer science after I graduate highschool. So I figured it would be good for me to learn to program now. My long-term goal is to get a job as a game programmer, but right now I just want to learn C++ since that is obviously very important. So I got the first book in this list. Im about half way through it and so far its been pretty helpful and I have made alot of progress. Once im done with that book I plan on continuing through the list, but Im not sure when(if ever) I should switch my focus from strictly C++ to game programming. I appreciate any advice, and Id rather get sent down the right path now, instead of wasting my time learning something im never gonna use. Thanks in advance =)
see above for a suggestion ^^
Ya I just noticed that someone replied, lol sry. Thanks for the advice, Ill read as many books on C++ and mess around with it as much as I can, but how long do you think it will take to get a good understanding on all those topics you listed, for the average person I mean, but I do have alot of free time that I can devote to it, so maybe I can do it a little faster than the average person =P
A breif look at memory management for you:
This a breif example of pointers and memory on the heapCode:#include <iostream> using std::cout; using std::cin; class Myclass { public: Myclass(); ~Myclass(); int getval() const { return *val; } private: int *val; }; Myclass::Myclass() { val = new int(5); } Myclass::~Myclass() { delete val; val = NULL; } int main ( void ) { Myclass *mc = new Myclass; cout << "Value of val is: " << mc->getval(); delete mc; mc = NULL; cin.get(); return 0; }
It all depends on how quicky you learn and pick it up. Remember, it is not just a case of copying the code and compiling itm you know the book code works. The idea and most important thing is to try things on your own. it took me ages to work out how pointers worked, but I got there in the end. Remeber, the compiler is your friend, it will help you! As will all of us here
Im off now, il view this thread tommorrow... hope my advice was useful to you.