What is the point of using the enum
keyword in the function parameter? It seems to do the same thing without it.
enum myEnum{
A, B, C
};
void x(myEnum e){}
void y(enum myEnum e){}
Is there a difference between the two?
What is the point of using the enum
keyword in the function parameter? It seems to do the same thing without it.
enum myEnum{
A, B, C
};
void x(myEnum e){}
void y(enum myEnum e){}
Is there a difference between the two?
In this function declaration
the enumeration myEnum shall be already declared and not hidden.
In this function declaration
there is used the so-called elaborated type name. If in the scope there is declared for example a variable with the name myEnum like
then using this function declaration
allows to refer to the enumeration with the name myEnum that without the keyword enum would be hidden by the declaration of the variable.
Here is a demonstrative program.
As it is seen the commented function declaration will not compile if to uncomment it.