Quote:
Originally Posted by Astralp
Well I tried using put() first, but could not get it to work for ints, and my lack of understanding for templates led me to just copy the put() code in my above functions.
|
The beauty of the template class stuff is that, even if you don't know much about it, you can still use it. You can simply do:
Code:
int mMyInt = 12345;
...
pChunk->Put(&mMyInt);
Quote:
Originally Posted by Astralp
I'm not sure about sizeof pointer, but I think that is how it is in put isn't it? Can't check at the moment.
|
No, ByteChunk::Put() does sizeof(T), not sizeof(pVal):
Code:
template <class T> inline int Put(const T* pVal)
{
int n = mBytes.GetSize();
mBytes.Resize(n + sizeof(T));
memcpy(mBytes.Get() + n, (BYTE*) pVal, sizeof(T));
return mBytes.GetSize();
}