Open
Description
小彭老师好,《现代C++入门:RAII内存管理》一课中提到的:初始化列表妙用,解决函数多返回值,更加fancy的写法无法编译通过。
示例代码:
struct {
bool b1;
double d1;
} test_anoy() {
return {false, 1.0};
}
编译错误:
test.cpp:9:1: error: new types may not be defined in a return type
9 | struct {
| ^~~~~~
test.cpp:9:1: note: (perhaps a semicolon is missing after the definition of ‘’)
Metadata
Assignees
Labels
No labels