Original Post
VC++2008, Direct3D9 Alright, I have the damn triangle on the screen now, good for me. But the more I write, the more I remember the hundreds of good things I could be doing... that I have completely forgotten. The back of my mind is vaguely screaming about these wrongs I'm committing while the front is just trying to learn like a person who doesn't know they exist. So here are some questions on the best ways to go about things. No need to answer all of them... bit of a wordy post this. 1. Some of the guides and tutes I'm looking at are declaring variables and objects right before they need to use them. For example: HWND hWindow = CreateWindow(blah blah blah); That feels a bit spontaneous to me, but of course makes sense when asked 'Why declare something until you know you need it?'. So do people advise declaring objects as much as possible at the top of their scope, or as close as possible to the point where they're needed? 2. Is it a good or bad thing to define a struct in a header? Is it a good or bad thing to have one header that includes practically everything and his dog, and all other files just include that header? 3. One quite recently made tute uses: delete [] myApp; It does this after calling a CleanUp() function to release the D3D objects floating around. I don't think I've used delete [] before. Why has this tutorial done this when the destructor is going to be called automatically anyway? Do you advise using delete [] explicitly? Is it not clearer to instead call the destructor explicitly? 4. In your WinMain(), what exactly is the point of return 1; ? And I've seen different examples, so is it: return 1; or return 0; or return wParam.whateverishotatthetime; ? 5. (Declaring and initialising.) Is it always advised to intialise (to null or 0 if need be) immediately after declaring a variable, instead of waiting until a time you need to assign something to it? To make it more complicated, I remember there being a difference between initialising on the same line as declaration, and initialising after the declaration is complete. Anyone know what I'm talking about and can point out when this difference matters? 6. (Sight between files.) When I use multiple .cpp files, the IDE is automatically making sure the compiler knows it has to include them all. Okay. And including a header is the same as pasting all the text from that header into the file that is including it. Okay. But can someone please give me some clarification on what "sight" there is between different .cpp files? I'm guessing/assuming that something declared at file scope (outside all the {} braces) is a global and can be seen from anywhere in any of the .cpp files. Correct? So it isn't possible to declare a variable that is only visible to the file it was declared in without actually putting it inside some braces. Right? 7. Could someone please simply recommend a good site that clearly explains all things C++. I imagine there's a popular one or two. (I really want to get into good const practice before I go much further.) That's all I can remember for now. Any other general helpful tips you think might fit with the above questions are welcome too. Cheers.