While debugging some code, I came across an array named default
. I thought that keywords were not allowed as variable names.
#include "stdafx.h"
#include <stdio.h>
int main()
{
int default = 5;
printf("%d\n", default);
return 0;
}
Now the above code compiles without a hitch on VS 2008. Isn't 'default' a keyword? How come it works as a variable name? Side-effects?
PS: Infragistics::Win::UltraWinToolbars::ToolbarsCollection
has a property with this name!
In Java, Using predefined class name as Class or Variable name is allowed.
A variable name must start with a letter or an underscore character (_) A variable name cannot start with a digit. A variable name can only contain alpha-numeric characters and underscores ( a-z, A-Z , 0-9 , and _ ) Variable names are case-sensitive (age, Age and AGE are three different variables)
By Convention: Variable names begin with a lowercase letter, and class names begin with an uppercase letter. If a variable name consists of more than one word, the words are joined together, and each word after the first begins with an uppercase letter, like this: isVisible .
A Variable name is used to refer to a variable (column of the data matrix) for all commands dealing with data in SPSS. The following rules apply when creating new variables or changing the name of an existing variable: Variable names must be unique in a Dataset.
It's a known issue in VC++. Basically by-design for C++/CLI compatibility.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With