Say I have
struct mystruct { };
Is there a difference between:
void foo(struct mystruct x){}
and
void foo(mystruct x){}
?
Not in the code you wrote. The only difference I know between using a specific class name with and without structis as follows:
struct
struct mystruct { }; void mystruct() {} void foo(struct mystruct x){} // compiles void foo(mystruct x){} // doesn't - for compatibility with C "mystruct" means the function
So, do not define a function with the same name as the class.
In C, the latter is invalid.
However, in C ++ they are almost the same: the first one will be valid, if you have not declared your structure at all, it will consider it as a direct declaration of an all-in-one parameter.
. ++; C.
Note that structboth classare essentially the same and both define a class, so there is no special reference to COD COD structures in C ++.
class
[Edit: There seems to be a slight difference, see Mark B.'s excellent answer.]