简体   繁体   中英

C++ enum value initialization

I have an enum declared in my code as:

enum REMOTE_CONN
{
    REMOTE_CONN_DEFAULT = 0,
    REMOTE_CONN_EX_MAN = 10000,
    REMOTE_CONN_SD_ANNOUNCE,
    REMOTE_CONN_SD_IO,
    REMOTE_CONN_AL,
    REMOTE_CONN_DS
};

I expect the value of REMOTE_CONN_SD_IO to be 10002, but when debugging the value of ((int)REMOTE_CONN_SD_IO) was given as 3.

Another component uses the same enum and it gives the expected value of 10002 to REMOTE_CONN_SD_IO.

What could be the reason for this?

OK, I'll guess.

The first component was built before you changed the code in the header. Try rebuilding the offending component.

一个可能的答案是,在您设置REMOTE_CONN_EN_MA = 10000后,可执行文件没有正确重建,因此您的调试内容与您正在查看的内容不符。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM