Since you can't use sizeof with a dynamically allocated object, I'm wondering if there's possibly a RTTI function that could return this for me? Or is it not possible?
Since you can't use sizeof with a dynamically allocated object, I'm wondering if there's possibly a RTTI function that could return this for me? Or is it not possible?
Keep track of the size as you allocate dynamically.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Or you could use smart containers like std::string and std::vector, which track the size for you.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
The problem is I'm modding a dll and don't have access to the exe code, so I can't track the size of objects whose classes are defined in the exe.
Objects of those classes should have some way of tracking the size, so use that. It should be similiar to Salem's suggestion of containers.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
unless the pointer is just a typedef for a void*, you could get the size from sizeof(*myPointer).
Oh, good point. If you are just talking about a single object, then yeah.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
[...]single object of the real object type[...]If you are just talking about a single object, then yeah.
If the object is of some derived class that will not help.
Soma
Okay, thanks for the suggestions.