开发者

C++: error: expected primary-expression

开发者 https://www.devze.com 2023-01-21 23:31 出处:网络
void add(int register, int& acc) { acc += register; } main.cpp:124: error: expected primary-开发者_开发百科expression before ‘register’
void add(int register, int& acc)
{
    acc += register;
}

main.cpp:124: error: expected primary-开发者_开发百科expression before ‘register’

wth is wrong right there?


"register" is a keyword in C++ (a hangover from C days, mostly)


register is a C++ keyword, rename this to something else. It's used to qualify variables as a hint to the compiler to optimize the variable's storage directly to a CPU register rather than RAM - see here.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号