I'm modifying some code I found to be inside a C++ object. Message is a c++ class.
The original line of code looks like this:
unsigned char fifoQueue[256 * sizeof(Message)] = {0};
Since I'm putting it into an object, I'm doing this:
///in header
unsigned char fifoQueue;
///in object initializer
fifoQueue = new unsigned char[256 * sizeof(Message)];
Somehow I don't think that is correct. What's the correct implementation to get the same result? I'm just a bit cloudy about how this works - In the given example fifoQueue is a pointer to a memory location, correct? Should my object have the fifoQueue instance variable as a pointer to a "Message" array, instead?
Thanks!
/////// Okay, I'm adding some information here that is relevant to the way this is being used. Sorry for not including this before.
There is a method that accesses this value as a pointer and increments it based on a read/write location. So I need the new initializer such that this method works correctly.
Message* Fifo::getMessageToWrite(){
Message* base = (Message*)fifoQueue;
return new(base + (fifoWritePtr & 255)) Message();
}