[英]Is the use of `struct` well-defined in c++ function signatures?
這個問題與另一個問題類似,但比另一個問題更具體:
考慮以下程序:
#include <stdio.h>
struct Foo {
int x;
int y;
};
Foo getFoo() {
Foo foo;
return foo;
}
int main(){
getFoo();
}
上面的程序使用g++
編譯,但不能使用gcc
。
我們可以按以下方式修改程序,使其可以同時使用gcc
和g++
進行編譯:
#include <stdio.h>
struct Foo {
int x;
int y;
};
struct Foo getFoo() {
struct Foo foo;
return foo;
}
int main(){
getFoo();
}
標准是否保證使用struct
關鍵字在C ++中定義良好 ?
是。 這被稱為詳細類型說明符 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.