开发者

Naming C++ Variables

开发者 https://www.devze.com 2023-02-14 15:27 出处:网络
I\'m learning c++. MY question is, is this a valid variable name? int @variableName I want to include the \'@\' symbol.

I'm learning c++.

MY question is, is this a valid variable name?

int @variableName

I want to include the '@' symbol.

Thank you. 开发者_开发百科


No, it's not a valid variable name. C++ only allows letters, digits and the underscore character, and the variable name cannot start with a digit.


No. In C++, and most languages, the only valid characters in variable names are a-z,A-Z, 0-9, and _. (And cannot start with a number).

int variableName; //fine
int _variable //fine
int 8variable //not fine
int @variable //not fine
0

精彩评论

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