Exactly.
This is the code:
As you will see function elementPtr() is returning a pointer to an
elemnt
of array. It has the index of the element * its size (m_elementSize) +
m_element which is from class CMemoryBlock.
I don't know why it complains for type cast ? Anyidea?
I will really appreciate it.
class CImageArrray {
public:
CImageArrray(unsigned long inElementSize = 0, long inBlockSize =
10);
virtual ~CImageArrray(void);
long numElements(void) const;
bool isEmpty(void) const;
unsigned long elementSize(void) const;
long blockSize(void) const;
etc ...
etc ...
private:
etc ...
protected:
// Instance variables:
CMemoryBlock m_elements; // Buffer of array items
etc ...
};
class CMemoryBlock {
public:
CMemoryBlock(unsigned long inSize = 0, bool inClearMem = false);
virtual ~CMemoryBlock(void);
etc ...
private:
};
void* CImageArrray::elementPtr(long inIndex) const
{
return ((unsigned char*) (void*) m_elements) + (inIndex *
m_elementSize);
}
Jay Nabonne wrote:
Then I suspect you need to call some of the methods on the object.
Or at least answer my question about what you expected the cast of the object to a pointer to accomplish. :)
Sorry, about your question:
It should return a pointer into the array at the specified index.
Does it have a method for accessing the data it contains? If so, you
would probably want to use that.
- Jay