Mar*_*k B 11

在C中,后者无效.

但是在C++中它们几乎是相同的:如果你还没有声明你的结构,第一个将是有效的,它会把它作为参数的前向声明一个对待.


Ste*_*sop 7

不在您编写的代码中.我知道在使用和不使用已定义的类名之间的唯一区别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
Run Code Online (Sandbox Code Playgroud)

因此,不要定义与类同名的函数.