这个问题与另一个问题类似,但更具体:
using struct keyword in variable declaration in C++
.
考虑以下程序:
#include <stdio.h>
struct Foo {
int x;
int y;
};
Foo getFoo() {
Foo foo;
return foo;
}
int main(){
getFoo();
}
上面的程序编译
g++
但不是
gcc
.
我们可以修改程序如下,使其与
海合会
和
克++
:
#include <stdio.h>
struct Foo {
int x;
int y;
};
struct Foo getFoo() {
struct Foo foo;
return foo;
}
int main(){
getFoo();
}
这是使用
struct
标准保证的关键字
定义明确
在C++中?