enum

Hi. I would like to know how this code works

Enum
{
ADC0,
ADC1,
ADC2,
ADC3,
ADC4,
ADC5,
};

It is used in an example code that I found ... I know how enum it works, but without instantiation I do not know what it means

google c++ enum

Try:

Serial.println(ADC0) ;

Serial.println(ADC5) ;

.

Hi. I would like to know how this code works

Enum

It doesn't work, because the keyword is "enum", unless "Enum" is defined in a macro.

This is an anonymous enumeration. The linked stack overflow page discusses some of the reasons why it would be preferred over more typical cosnt int variables.

It is called anonymous because it it given no name, so you can't declare any variables with the type of that enum. Its sole purpose is to use the enumeration values as numerical constants.

Juraj:
google c++ enum

"I know how enum it works, but without instantiation I do not know what it means"

dforchetti:
"I know how enum it works, but without instantiation I do not know what it means"

That just means that when you googled "C++ enum" you didn't read far enough. Anonymous enum is usually covered pretty early on.

Jiggy-Ninja:
This is an anonymous enumeration. The linked stack overflow page discusses some of the reasons why it would be preferred over more typical cosnt int variables.

It is called anonymous because it it given no name, so you can't declare any variables with the type of that enum. Its sole purpose is to use the enumeration values as numerical constants.

Thanks .... I didnt know this kind of use of enum....