Hi, I believe this is my first posting to DaniWeb, so thanks very much in advance for your time!
I have been doing some searching and I am not sure of a definitive answer to the following problem. I am attempting to make a class that can store a set of pointers to generic data, and what I had started to do was use a void* for each piece of data, contained in a data item wrapper class. That allows me to do the following, where _pData is a void*:
pSomeItem->_pData = pSomeClassPointer;
// ...other code here...
pDifferentClassPointer = reinterpret_cast<SomeClass*>(pSomeItem->_pData);
Unfortunately, some brief searching has left me uneasy about whether C++ really guarantees that all pointers to objects (i.e. SomeClass) and primitives (i.e. long int, char, etc.) will be the same size. I would guess that this is usually the case on 32-bit and 64-bit Intel systems, and I am not writing this code for obscure or embedded systems, but I would still like to know the correct way to do this if possible, and any sort of references if a C++ standard or some other source guarantees it.
From my reading I have gathered that function/method pointers may well have different sizes, and that is not a problem for me since I only want to store pointers to data.
If the above is NOT the case, does anyone have a suggestion for a solution? The only solution I can think of so far to store a pointer to a generic piece of data is to use templates and declare the data collection to use that type.
Thanks again for your time!