parallel101 / parallel101/course
函数返回匿名结构体无法编译
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 4.2k
- Forks
- 556
- PR merge metrics
- No merged PRs in 30d
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 ‘’)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the lesson 《现代C++入门:RAII内存管理》 and its example for returning multiple values with an anonymous struct. Reproduce the reported compiler error with the shown snippet, then confirm the lesson's example is updated to valid C++ and compiles successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100