以下使用Java写的一段代码:
public synchronized byte[] getAsByteArray() {ByteBuffer buffer = ByteBuffer.allocate(packet_size+10);
buffer.order(Constants.PACKET_BYTEORDER);buffer.put(STRUCT_HEADER.getBytes());//放入char类型
buffer.putInt(STRUCT_VERSION);//放入unsigned long int 类型buffer.put(playersPerTeam);
buffer.put(gameState);
buffer.put(firstHalf);
buffer.put(kickOffTeam);
buffer.put(secondaryState);
buffer.put(dropInTeam);
buffer.putShort(dropInTime);
buffer.putInt(estimatedSecs););//放入unsigned int 类型
// blue teambuffer.put((byte)getTeamNumber(Constants.TEAM_BLUE));
buffer.put((byte)Constants.TEAM_BLUE);
buffer.putShort((short)getScore(Constants.TEAM_BLUE));
buffer.rewind();
        byte[] array = new byte[packet_size];
        buffer.get(array);
        return array;
    }
    具体来说就是将一些unsigned long int 和unsigned int数据放到buffer中之后再将这个缓冲区的字节都付给byte数组array.之后将array之中的内容用UDP发出去(发送程序没写).但在C++中好像没有ByteBuffer这种类型,请问c++中应该如何编写完成这样功能的程序?万分感谢!