I'm looking to make gmod modules but obviously to do that I need a solid understanding of C++. I'm at a pretty solid stage with Lua, so that won't be a problem. I'm currently doing Java in school (which is piss-easy (at least at the lower stages)). I bought C++ for dummies a while back but got confused around the pointers section.
Any tutorials Facepunch would recommend for syntax or structures of C++?
I never understood why people had trouble with pointers.
A pointer is the address of a value in memory.
Pointers, themselves, are values in memory, so you can have pointers to pointers to pointers if you want.
Arrays in C/C++ are really just syntactic sugar for pointer operations.
For example,
[code]
uint8_t data[3];
data[0] = 1;
data[1] = 2;
data[2] = data[0] + data[1];[/code]
is the equivalent to
[code]
uint8_t data[3];
*data = 1;
*(data+1) = 2;
*(data+2) = *data + *(data+1);[/code]
The array declaration "uint8_t data[3]" allocates space for three 8-bit unsigned integers on the stack and stores the pointer to the first value in "data".
See, if someone had've pointed that out, I'd have gotten the hang of it long ago.
[QUOTE=Disseminate;23954990]See, if someone had've pointed that out, I'd have gotten the hang of it long ago.[/QUOTE]
Don't worry, most people are utterly confused about pointers before something just 'clicks' :smile:
It's one of those things that you wonder how you could have not understood it at one point once you understand it.
[QUOTE=Disseminate;23954990]See, if someone had've pointed that out, I'd have gotten the hang of it long ago.[/QUOTE]
Sounds like you need a better book.
[QUOTE=jA_cOp;23976813]Sounds like you need a better book.[/QUOTE]
This. I understood pointers the first time I went through that chapter of my book.
Sorry, you need to Log In to post a reply to this thread.