I really couldn’t get it.
But now I do.
The problem traces back to this example, which I won’t say anything bad about, except:
MYSQL *connection, mysql;
Now I’m pretty good with C++. I really am. But I ( forgot ? whoops : did not know) that this declaration creates:
- A variable, static type MYSQL *, identifier ‘connection’
- Another variable, static type MYSQL, identifier ‘mysql’
Did you NOT just do a double take?
Let me further elaborate.
The following lines of code ARE NOT EQUIVALENT to the bolded line above
MYSQL *connection ;
MYSQL * mysql ;
Which is effectively what I did, and which is why I got the well deserved
Unhandled exception at 0×1000edb7 in MYSQL_CLIENT_2005.exe: 0xC0000005: Access violation writing location 0×000003b0.
So the declaration:
MYSQL *connection, mysql;
When broken into 2 lines is:
MYSQL *connection ;
MYSQL mysql ;
Really, I don’t like how that is. Basically the “pointer” part of the declaration sticks to the identifier, NOT to the type specifier at the front.
I thought I could make 10 int pointers like:
int * a,b,c,d,e,f,g,h,i,j ;
But it turns out you’ve have to do:
int *a, *b, *c, *d, *e, *f, *g, *h, *i, *j ;
We all learn..