用C ++返回数组 [英] 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<double>
这样的实际容器.我认为不可能从函数返回数组.
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 ++返回数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文