Luc*_*ore 5 c++ struct function-signature
说我有
struct mystruct
{
};
Run Code Online (Sandbox Code Playgroud)
是否有区别:
void foo(struct mystruct x){}
Run Code Online (Sandbox Code Playgroud)
和
void foo(mystruct x){}
Run Code Online (Sandbox Code Playgroud)
?
不在您编写的代码中.我知道在使用和不使用已定义的类名之间的唯一区别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)
因此,不要定义与类同名的函数.
| 归档时间: |
|
| 查看次数: |
1167 次 |
| 最近记录: |