1. You have to understand I'm describing the casting as: *(cILTClient**) as a:
the
[value of] ( [pointer to] a [pointer to] an (Interface for a LithTech Client)
).
if you don't know any C++ very well this will be difficult if not impossible to understand, but when casting we force a value to behave like another type. For instance if I had:
Code:
int c = 0;
double b = 0.999;
c = (int) b;
I am forcing one data type to another. In your original code you had an address... 0x377ED910
This is just a number. It does not matter that it is in hexadecimal format. Your compiler would treat it as a
long type. Since we want to treat this number as the address of our LTClient pointer we must cast this number as that.
Now what stores addresses? That's right pointers. So if 0x377ED910 was say a variable it would be the same as this:
Code:
&pILTClient == 0x377ED910
So you see the actual location in memory where pILTClient chills at is 0x377ED910 . That's his home. If you knock on his door he'll come out, but his address is not him. Just like your address is not you, it's just where your at.
This cast says:
Code:
pILTClient = *(cILTClient**)0x377ED910;
I want to find pILTClient. I don't know where he's at, but I know his home address. In a way since we can find pILTClient by his address we say that his "home address" or 0x377ED910 points to him. Now that we have his home address I can
NOT go ahead and say that:
Code:
pILTClient = 0x377ED910;
That is like saying your address is you! or I am Swadley rd. APT 55, lol. I'm not an apartment! I'm a person! SO we must open the door at that address to see who's inside. The "*" in front of (cILTClient**) means "open this door" or "value of". So:
*(cILTClient**)0x377ED910 = open the door at apartment "0x377ED910" and get the (ILTClient*) person who lives there.
Now we want to move that person to a new home which will be the address of our variable pILTClient.
Code:
pILTClient = *(ILTClient**)0x377ED910;
yeh our person has a new home! We will call that person pILTClient. And his home is &pILTCLient, but we can just call him pILTClient directly now, and don't have to knock on his door anymore. Since we have gave him a name we can just call him pILTClient like I would talk and refer to you as Aqollo now.
Even though before when I didn't know your name I had to refer to you by your address:
Code:
Aqollo = that guy who lives in Swadley rd. APT.55, Canada
(I know that's not where u live I'm making this up)
So we could say:
Code:
Person = Aqollo;
Aqollo = *(Person*)Swadley rd. APT. 55; //open door at address
Now if you had a watch on then I could find that watch by finding you
Code:
Watch* Aqollo;
Aqollo = *(Watch**)Swadley APT.55;
So I can find the watch by finding Aqollo so Aqollo "points to the watch". If I don't know Aqollo I can find the watch by finding Aqollo address. His address Swadley rd. (0x377ED910) [points to] Aqollo and Aqollo points to his watch. A watch is the end of the chain so we say
Watch** because there were two levels of indirection before we get to the watch. Look familiar?
Code:
ILTClient* pILTClient;
pILTClient = *(ILTClient**)0x377ED910; //open door at address
As you become more proficient you can drop all the mnemonics and memory devices I used and just start saying "the value of" and "points to", but for now I think it would be a good idea if you wrote everything out the way I did. Remember 0x377ED910 is just a number just like Swadley rd. is just a word. I have to treat it like an adress to use it. 0x377ED910 is pILTClient's home and if you want to see him you have to open the door. Finally try thinking a little more generally. pILTClient though we treated him like a person is actually a pointer himself. and what he contains is an ILTClient in his pocket or whatever. So we could treat pILTClient's as the home of ILTClient. It's really only a matter of perspective. Go ahead and experiment a little. However I recommend you only look at the perspective of one pointer at a time. Take your time, because you don't want to be thinking ILTClient and pILTClient share the same house, this is where this memory device breaks down! pointers only reference one thing! do not take this memory device and then try to infer other things out of it. If you get to that point it is time to move on and put the memory devices behind you.
I'll get to the rest of the questions later.