Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
OzyMandrill
Aug 12, 2013

Look upon my words
and despair

Shadow0 posted:

Also, the & and * are part of the variable type and belong next to that, not the variable name, which it has nothing to do with.

I thought this for decades, I mean it's obvious? But then I read Stroustrup and learned it is wrong. A pointer is a special virtual thing. To turn it into an actual thing you dereference it with a star, so *(a pointer) = a thing, therefore you define a thing named (*name) then name is a pointer, cos *name is the thing. And cos if you write a list like:
code:
int a, *b, c, *d;  // Lawful Evil
then b & d are pointers to ints, and a and c are ints, and

also:
code:
int* a,b,c;  // Chaotic Evil
defines a as a pointer and b,c as ints.

There is a dedicated circle of hell for people who would use any of this in any actual code.

my mind was so blown by this obvious reasoning I forgot to look up why the '&' does the same. I think the answer for that is a because-it-does-you-wanna-start-something shrug.

OzyMandrill fucked around with this message at 15:43 on Oct 30, 2022

Adbot
ADBOT LOVES YOU

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply