When reading out of a textbook, is it good practice to write your code while looking at examples in the book? Is there any tips or advice someone can give when it comes to learning C++ from a book?
Of course it is. How else will you figure out how the code works? Just make sure you take the time to figure out what the code you're looking at is doing rather than just copying it verbatim. If you take the time to review the example(s) properly, you will get the underlying concept, not just the code. If you can get the underlying concept, you will now have the knowledge/power to adapt your code to new situations.
Agreed. It is also good practice to play around with the example codes. For example if you are not sure why a particular line code is there or why the author does something in a particular way, you can just change it and see what happens. It's good to also skim through the book, to get an idea of what you are going to learn from it, and start an ongoing project that incorporates most of the concepts of the book, and develop the parts incrementally as you learn the new concepts. This way you get a bit of independent problem solving skills rather than just a theoretical understanding of the concepts, it helps to really understand the "why" and the "what is this good/useful for".
So I would suggest you take the examples from the book, compile them, tweak them around to make sure you understand everything about it that might be unclear from the book's explanation, and once you are comfortable with that "lesson" try to incorporate it in your ongoing "bigger" project if applicable (but don't make the project too big at first, you can always switch to a bigger project later, if you accomplish everything).
If you have any problems along the way, you know where to post a thread to get help ;)
take examples verbatim and see WHAT it does by compiling and running it
Then fiddle with them doing some modification and see HOW it works
You can as well use the authors idea in an example to create something new, that is after you understand it. The author probably is just trying to give a central idea, its your turn to know give it a twist.