That being said, if you want to do 2d programming, SFML is an excellent library. Together with for example Box2D for physics you can make some really cool stuff:) For 3d you could go with Irrlicht or Ogre3d, both of which are 3d graphics engines for C++, but if you wanted to get into the nitty-gritty of it you should check out the NeHe tutorials on OpenGL!
Thanks for the advice! What exactly do you mean by pitfalls? Also I have been wondering the following for a long time: In most java/c++ related languages the main function/object is called main. I'm pretty sure its int main in c++. Is this optional (it being called main) or mandatory? If it is optional, how does the compiler know that that is the main function, and not just some other random function? Thx
Is this optional (it being called main) or mandatory?
It's mandatory if you're writing a "hosted" application (that is, a program that will be executed by an operating system). The OS, to put it simple, will make a call to main() in order to start executing your code.
It is optional if you're writing a "freestanding" application (that is, an OS kernel, a boot loader, etc), where something other than an OS is going to choose where to start executing your code.
In C++, unlike a lot of the higher level languages such as Java, you are responsible for allocating and unallocating memory. This is done with the new keyword and the delete keyword. After that, you must understand how pointers work. A pointer is like an address to a house, and a non-pointer variable is like the house itself. For a long time, I did not know how this would be used. Pointers are used to allow other parts of your code be passed a small amount of data (just a 32 bit or 64 bit pointer), so that the OS does not have to copy the entire amount of data that you have stored to a different location. Pointer can also be used to allow other functions change the data in the pointers.
Also, order of operations are important, especially in if statements.
One last thing that got me when I was a beginner, if (x = 0) return 0; will set x to 0 and then evaluate if it is not 0. This will always fail. Soon afterwards, I was able to figure out that you should use == to evaluate, rather than just and = sign. C++ does not mark it as an error, where Java would.
You can learn C++ anywhere throughout the internet, and since you're sounding pretty confident of yourself (which is indeed a good thing) that you can easily grasp the C++ knowledge that you need, then looking up some random tutorials on youtube should do the job well. However, if you're serious about learning C++ and not just the 'basics' i suggest you buy a book or something, because C++ is not an easy language to learn and fully understand, i remember it took me well over 8 months to learn just the basics back when i was 14, i didn't have any previous programming experience at that time though, so it shouldn't take you as much time as it took me, but still, i honestly doubt that you can learn all the basics of the language within a week. Anyways what i'm really trying to say is learning C++ will not be as easy as you might think, you will have to read, work and experiment, you will be challenged at times but never overwhelmed trust me, you will have fun while learning.
Last edited on
Topic archived. No new replies allowed.
You are using a version without Ads of this website. Please, consider donating: