What is actualy a pointer....[Resolved]
At school they though us it is just a "storage room" for an adress. But if it was only that, why do we den have diffrent types of pointers. Like a pointer to an object from class A and an other one that points to an object from Class B. And pointer that points at A, can't be used to point to B....why is that? If it was just a adrees it would not care...would it?
Not sure why I have never thought about this before.....hmmmm...
ØØ
Re: What is actualy a pointer....
Quote:
Originally posted by NoteMe
At school they though us it is just a "storage room" for an adress. But if it was only that, why do we den have diffrent types of pointers. Like a pointer to an object from class A and an other one that points to an object from Class B. And pointer that points at A, can't be used to point to B....why is that? If it was just a adrees it would not care...would it?
Not sure why I have never thought about this before.....hmmmm...
ØØ
Well internally that is all a pointer is, just a 32 bit address. The compiler forces rules on you however, with how you are able to manipulate that address.
The magic of polymorhism in C++ is done with whats called a v-table. That's how the compiler keeps track of the objects.
Re: Re: What is actualy a pointer....
Quote:
Originally posted by Maven
Well internally that is all a pointer is, just a 32 bit address. The compiler forces rules on you however, with how you are able to manipulate that address.
The magic of polymorhism in C++ is done with whats called a v-table. That's how the compiler keeps track of the objects.
Yeah I have figgured that now. But as long as I only inherits from one base class, the derived classes will only have one v-table. And I wanted to test the perfomance of it and see how much slower it is then not having a v-table.
What I want is actualy to have a pointer that can point to what ever object that has derived from that base class, so I can call a Render function. But I thought that CornedBee said that I could do that if the base class had a viritual function, and the derived classes where inheriting from it....:(