I have an issue with C++ and creating a reference byte[].
In C# my method is:
public static void SetBitAt(ref byte[] Buffer, int Pos, int Bit, bool Value)
    {
        byte[] Mask = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
        if (Bit < 0) Bit = 0;
        if (Bit > 7) Bit = 7;
        if (Value)
            Buffer[Pos] = (byte)(Buffer[Pos] | Mask[Bit]);
        else
            Buffer[Pos] = (byte)(Buffer[Pos] & ~Mask[Bit]);
    }
I want to translate it to C++, but I can't get the refworking for C++. I saw something about the & symbol and I tried something like this: 
void SetBitAt(byte& buffer[], int Pos, int Bit, bool Value)
{
    byte Mask[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
    if (Bit < 0) Bit = 0;
    if (Bit > 7) Bit = 7;
    if (Value)
    {
        buffer[Pos] = (byte)(buffer[Pos] | Mask[Bit]);
    }
    else
    {
        buffer[Pos] = (byte)(buffer[Pos] & ~Mask[Bit]);
    }
}
but then I get the Error:
'buffer': arrays of references are illegal.
So how can I change my C++ code to work with a reference array?
EDIT: I use this method for setting a buffer, but it doesn't change when I use this method.
other class:
buffer = ReadDB(2);          //Read the values in the DataBlock
SetBitAt(buffer, 0,0 true);  //Set bit 0,0 to 1(true)
WriteDB(2, buffer);          //Write the values to the Datablock
but the buffer doesn't change. its the same value.
 
     
     
     
    