You can learn how to code…

professional and modern C++ a lot easier than colleges make it seem. And why not have fun at the same time? You don't need a lot of math. This book explains everything you need from the absolute beginning. Learn skills as needed so you can understand why they are useful and when to apply them.

View a topic from Chapter 3 ↓
Claim Your Preview of Chapters 1-3
ront cover of book How To Code C++ From A Simple Idea


[previous topic introducing references as a new name]

How are references really used in code?

That's interesting, I suppose. But you might wonder, "If a reference just establishes a new name for an existing variable, then why is it needed? Why can't the code continue using the current variable name?"

You would be correct. And that's why references are not used like this. It's a good way to introduce them. But it leaves the real use unanswered. Maybe other books hope you won't ask the obvious questions. I don't know why they leave it like that.

Here's why references are really needed.

References are almost entirely used by method parameters. You'll also find them used in method return types and in range-based for loops. And in some other places that you'll learn about later. Methods are the big use case though.

Remember I said that when you pass a variable to a method as an argument, that the method gets its own copy in its parameter and cannot modify the caller's variable? What if that parameter was a reference?

That would let the method use and even modify its parameter like normal. And the whole time, it would actually be working with the caller's variable directly. This lets a method modify an argument passed to the method when the method is called.

You now have another way to get information out of a method call. You can use the return value and you can also let the method modify your variable arguments for you.

And it gets more interesting when the return type is a reference. This lets the method give you a reference to some other variable. You can then modify this reference which affects the original variable.

You need to be careful with references. There are some gotchas that will crash your program if you don't know about them. I'll explain all that in just a moment.


This preview of chapters 1-3 is already huge...

at 323 pages. This is why the eBook is not available on Amazon; they would only let me give away 80 pages from the full eBook. You need more than that to get started. After following these first three chapters, you'll have a firm understanding of fundamental skills and will be ready to continue your journey.


I’m Abdul Wahid Tanner and have been programming C++ since 1992.

And teaching others how to code for almost as long. Back then, there were no books to teach C++ and I learned everything by experimenting. I know the difficulties of learning how to code and can help you in your journey.

This book contains decades of insights and follows a learn-as-you-go style. It also contains some mistakes because we can all learn from those. This is a practical approach that doesn't try to hide anything and lets you understand how to code. This is how real code is written.

©2020 Take Up Code. All rights reserved. Privacy Policy