Jason
Jason

Reputation: 11

Naming C++ Variables

I'm learning c++.

MY question is, is this a valid variable name?

int @variableName

I want to include the '@' symbol.

Thank you.

Upvotes: 1

Views: 855

Answers (2)

PrettyPrincessKitty FS
PrettyPrincessKitty FS

Reputation: 6400

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

Upvotes: 3

Tim Martin
Tim Martin

Reputation: 3697

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.

Upvotes: 6

Related Questions