c++ - C++ 中的返回数组

标签 c++ arrays return

我是一个彻头彻尾的 C++ 菜鸟,我在从我的方法返回数组时遇到了一些问题。我有一个包含以下方法声明的头文件:

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

返回数组的正确方法是什么?

最佳答案

C++ 不能很好地处理非本地数组,更有可能你应该使用像 std::array<double,10> 这样的实际容器或 std::vector<double> .我认为不可能从函数返回数组。

关于c++ - C++ 中的返回数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7936351/

相关文章:

c++ - 初始化多 channel OpenCV Mat

c++ - 在 vector 中查找字符串的索引

c++ - 必要时违反继承之上的组合可以吗?

javascript - jQuery 根据用户输入从数组中获取值

c++ - char 数组末尾的奇怪字符

c - 回到循环 C 的开始

c - 返回后的函数 kepps(递归 C)

c++ - getchar 或 cin.get() 在开发 cpp 中不起作用

java - 如何将多个 &lt;input type =“checkbox”/> 作为数组发送到 Java servlet?

Java toString 方法 - 打印不正确