course icon indicating copy to clipboard operation
course copied to clipboard

函数返回匿名结构体无法编译

Open MrSoul8715 opened this issue 1 year ago • 2 comments

小彭老师好,《现代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 ‘’)

MrSoul8715 avatar Oct 18 '24 07:10 MrSoul8715