I cannot comment about RTTI, I have not really used it.
If you want to understand pointer, maybe you can study the code of the
GetRGB function in this thread:
https://forum.lazarus.freepascal.org/index.php/topic,37242.msg252828.html#msg252828The information of pixels' colors are stored in the memory as an array. Some image types need 24 bit data for a single pixel but some others need 32 bit data for a single pixel. To simplified the code, I used
absolute statement to set both
Data24bit and
Data32bit to occupy the same location of
ScanData. (see
lines #123 and
#124)
The ScanData itself is a pointer. Because it is a pointer so I can point it to the memory location where the image data stores the pixel information. With the help of Data24bit and Data32bit, which are
PRGBTriple and
PRGBQuad, so can read the red, blue, green information easily.
So, what is a pointer typed variable? I would say it a variable that we can point it to any memory location, so we can easily read/write the data in the memory. For example you can use
Inc function to make the pointer to point to the next memory location (see
line #130,
#138)
When 'playing' with pointers, you often need to use these symbols:
@ and
^. You can check the documentation, what they mean and when to use them.
Another example is using pointer to create a keyboard buffer, which is very useful in game programming. In the thread in the link below, I showed how to manually using pointer and TList to create a keyboard buffer instead of using the ready-made TQueue.
https://forum.lazarus.freepascal.org/index.php/topic,38136.msg261965.html#msg261965
And if you want a more advanced example, yep I have it:
https://forum.lazarus.freepascal.org/index.php/topic,54548.msg406283.html#msg406283To solve the case as requested by the OP in the thread, I need to store the information of the objects which must be unique. The only think in my head was the memory location of the object. So I used
PtrInt(Button).ToString (see
lines #69,
#78,
#92,
#107). If you want to learn more about PtrInt, read here:
https://www.freepascal.org/docs-html/rtl/system/ptrint.html