My New C++ Endeavors

Awesome news! I’ve been asked at work to start doing a bit of GUI development for our NASA projects. They’ve said that all of their stuff is developed using Borland C++. Now with my PennMUSH development experience, I’ve taught myself a bit of C++ (though my PennMUSH development experience has been mostly debugging and making sure it compiles under Windows, so it isn’t too in depth).

One of the big hangups I’ve always had with C++ is the pointer and reference concepts. And I think I know why now. It’s because immediately after teaching us pointers in college, our teacher jumped right into recursion. And it was hard enough grasping pointers without sending my mind into an out-of-control fractal spiral.

However, reading C++ All-in-One for Dummies (the big 7-volume one that I got at Barnes and Noble for a surprising $35), the entire concept of pointers suddenly made sense to me!!

Here it is in a nutshell:

  • Variable has a value.
  • Pointer has a value also. Its value is actually a hex word.
  • Pointer’s value, that hex word, points at the memory location of the variable.
  • We can access the variable’s value via the pointer, which expands our capabilities of manipulating it.

And in short:

As you can see, all we REALLY care about in the end is what or where the variable is.

Then we get into heap variables where we don’t even care what the variable is called! We only work with it via pointers!

Then apparently C++ has this new thing that wasn’t in C called Referencing. This is, at least from what I know, a shorthand way of passing actual variables in and out of functions.

Functions normally just pass variable values in and out:

With references, we can actually change the VARIABLE we pass in:

Leave a Reply

Your email address will not be published. Required fields are marked *