Say I have
struct mystruct
{
};
Is there a difference between:
void foo(struct mystruct x){}
and
void foo(mystruct x){}
?
In C the latter isn't valid.
However in C++ they're almost the same: The first one would be valid if you haven't yet declared your struct at all, it would treat it as a forward declaration of the parameter all in one.
Not in the code you've written. The only difference I know of between using a defined class name with and without struct
is the following:
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, don't define a function with the same name as a class.
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