I have just gotten a book called programming 2d games by charles kelly(using c++) The book teaches direct x9.
I have finished learning all the basics in c++ such as classes and pointers etc.
Direct x is so difficult i can't get my head around it! I really want to develop games, but when i start reading the book, the code discourages me.
You must understand the DirectX interface and the API functions associated with it. You use COM objects to communicate with the DirectX device, which you will use to control the majority of rendering functionality. The D3DX, or DirectX eXtra library is a set of useful structures/functions you use to help you do this, such as the mathematical operations to multiply matrices.
If you plan to make games with DirectX, you should use Visual Studio as your IDE and the DirectX Debugger, which integrates DX errors to your output window while debugging. You can also use PIX to debug things like shaders. You should see the DirectX documentation on msdn, the DirectX sample browser, and if it helps, tutorials like http://www.directxtutorial.com/.
If you aren't familiar with the concepts and methodologies used in these sources, you should educate yourself more on whatever specific topic you don't completely understand. More often than not, you'll go on a tangent to learn something that seems irrelevant to what you want to learn (i.e. game programming), but I assure you that these all play a detrimental role no matter how irrelevant they may seem to apply to what you want to do.