How did you learn C++?

I'm around halfway through reading "Sam's Teach yourself C++ in an hour a day" and I'm finding a lot of useful stuff in here, although all the basics are taught in the first 8 chapters, I'm now up to chapter 13 and I'm finding myself not really taking in what it's teaching, there's a lot of complex stuff, It's not that I don't understand it, it's that I don't see the point in it, Currently I'm going through each chapter and writing down in notepad all new things I've learnt in that chapter, But I don't really feel like my programming skills are improving, If I was asked to program something I still feel like I'd just use the basics from the first 8 chapters, I was just wondering how everybody else learnt C++ and whether they think I should continue on reading the more complex side or whether I should find tasks or something I can do that actually show the right situation of when I should use what. For example, pointers are included in the basics, and I know what pointers are and how to use them, but I still don't know WHEN I should use them.
All of that really depends on your style of learning. Many complex problems can be solved using basic methods (but more efficient solutions generally require more complex methods).
You can use pointers when you need to access either the memory address of a variable/object, or when you need to modify the value of the thing that the pointer is pointing to. They are very useful, but there's almost always a way around it. Pointers are necessary when dynamically creating arrays (especially multidimensional arrays).

I learned(am still learning) C++ in formal college courses. The topics were drilled in with assignments in which we HAD to use a certain concept in order to get a full score. Figuring out when to use certain tools just takes practice and, as frustrating as it is, you just have to keep pushing through it.

Try doing some exercises (I don't know if you book has some - I'm sure it does), and make yourself use the concepts that were introduced in that chapter. It may not make sense at that moment to use those concepts, but you'll begin to get an understanding of how/why to use them, and also when you shouldn't use them.
It is also important too to also understand that programming is really not about the syntax. I did not earn this until college but syntax is just that, syntax. You can learn all the code you want but it does not mean you will know what you are doing. The books usually do not offer real programming challenges that you really need in order to develop problem solving skills so try to look around for some challenges. Some common/intro ones would be writing functions that do things like calculate your grade in a class, convert a binary string to an integer and checking to see if a string is palindrome or not. More advanced challenges would be implementing some sorting algorithms like bubble sort, selection, insertion and then into quicksort, merge sort and binary search.

erock

Its not as easy as simply reading a book, a lot of your learning comes from experimenting with the individual instructions in stages using a development environment.

For example, when you learn loops, try and write a simple tables program that asks what table, loops 12 times and uses the loop variable and what the user entered to calculate the result - programming is all about problem solving and having some patience :)

You may feel what your reading is pointless and very basic, for example the IF statement.. you may be doing simple things like

1
2
if(num > 10)
cout << "Number was higher than 10";


which to most would think.. what use is this in the real world? - yet its learning you what IF statements do and why they are used. Those IF statements, Switch statements, Loops and all the other stuff in your book (although examples may be basic ) are used in today's high performance game engines - i.e. checking if a player collides with a wall, standing on the floor and more.

If you are getting to chapter 13 and feel like your not taking it in, then you shouldn't be at chapter 13. Move on up to the next chapter when you are clear on the previous chapter and have experimented with the information you have learned.

Anyway, from a personal point I stared learning programming at the age of 12, reading books, experimenting with what I learned (without using the book as a reference) and later writing simple programs, things like the tables program i said earlier, tic tac toe, checkers and so on - those were in a console and nothing special, yet the important thing here was I was learning what each command did and getting more experience along the way.

Learning C++ doesn't happen overnight, and certainly not in half a day like the books title states.


Topic archived. No new replies allowed.