Is this chapter even valid?


Admittedly, I’m (somewhat) young, inexperienced, and a bit of a smartass… But isn’t the concept of pass-by-reference strictly C++?

I’m fairly certain that you can only pass by-value in C. And while you can dereference pointers, there is no syntax for references.

Take the example on p71. When you pass &integerPointer to modf, you’re actually passing by-value the address of the pointer. The function signature of modf probably looks something like…

The function [i]modf[/i] would then receive a copy (which is wholly owns) of *returnedInt, dereference the pointer and update that value at that address.

The concept of pass-by-reference would be something like…

…where the second argument would actually be a reference to a value stored in the stack frame of the calling function.

Sure, the actual value of integerPart is still stored in main()'s stack frame… but it’s a different concept for updating that value.

Anyway, I just was looking for clarification/discussion :slight_smile: … I’m actually about 120 pages into this book, and honestly, I love it! It’s one of the few guide books that I’ve found to be readable. Thanks!


Passing something by reference in this book means passing its address:

void Foo (Bar * bar);

In C++ world, you can pass something by reference and access it by using two different forms of syntax:

void Wipe (long * code)
   if (! * code) {
        * code = 0;
void Wipe (long & code)
   if (!code) {
        code = 0;

They are functionally equivalent.