Return array in C++(在 C++ 中返回数组)
问题描述
我是一个完全的 C++ 菜鸟,我在从我的方法返回一个数组时遇到了一些麻烦.我有一个带有以下方法声明的头文件:
I am a total C++ noob, and I am having some trouble returning an array from my methods. I have a header file with the following method declaration:
virtual double[]
echoDoubleArray(double[] doubleArray, int arraySize) throw (RemoteException);
这给了我以下错误:
../common/EchoService.h: At global scope:
../common/EchoService.h:25: error: expected unqualified-id before ‘[’ token
返回数组的正确方法是什么?
What is the correct way to return an array?
推荐答案
C++ 不能很好地处理非本地数组,你更可能应该使用像 std::array<double,10> 这样的实际容器;
或 std::vector
.我认为不可能从函数返回数组.
C++ doesn't play nice with non-local arrays, more likely you should be using an actual container like std::array<double,10>
or std::vector<double>
. I don't think it's possible to return an array from a function.
这篇关于在 C++ 中返回数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 C++ 中返回数组


- 静态初始化顺序失败 2022-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- C++ 协变模板 2021-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 近似搜索的工作原理 2021-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 从python回调到c++的选项 2022-11-16
- 使用/clr 时出现 LNK2022 错误 2022-01-01