Skip to content

CPP函数如何安全返回数组 | 编程之禅 #94

@wangjunstf

Description

@wangjunstf

https://wangjunstf.github.io/2025/10/08/cpp-han-shu-ru-he-an-quan-fan-hui-shu-zu/

因为数组不能拷贝,所以函数不能返回数组,不过,函数可以返回数组的指针或引用。在现代 C++ 中,我们应该优先使用标准库容器而不是 C 风格的原始数组和指针,比如std::array和std::vector。

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions