gpt4 book ai didi

c++ - 类声明错误

转载 作者:太空宇宙 更新时间:2023-11-04 15:06:35 25 4
gpt4 key购买 nike

我尝试在 C++ 中声明以下类;但是,我收到以下错误。指针有问题吗?

class classFather{
public:
int BmcCommand;
int BmcDataLength;
byte BmcDataBuffer[];

classFather() {
BmcCommand = 0;
BmcDataLength = 0;
BmcDataBuffer = new byte[CMD_LENGTHH];
}

classFather(byte s8Command, int siLength, byte as8Data[]) {
BmcCommand = s8Command;
BmcDataLength = siLength;
int size = sizeof( as8Data ) / sizeof( as8Data[0] );
BmcDataBuffer = new byte[size];
for(int ii=0; ii< size; ii++)
BmcDataBuffer[ii] = as8Data[ii];
}
private:
static const short CMD_LENGTHH = 255;
};

我收到以下错误:

error: incompatible types in assignment of `byte*' to `byte[0u]'
C:\....\BluetoothClient\/msgCAN.h: In constructor `msgCANFather::msgCANFather(byte, int, byte*)':

最佳答案

您在 byte BmcDataBuffer[] 之后缺少一个 ; 并且类声明看起来也是错误的:classFather{ 应该是 class Father { 我猜。

关于c++ - 类声明错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13050939/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com