Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一堂课:
class cAsset{ public: void data(int); int returnInfo(void); }
和一个假设返回 cAssets 数组的函数
cAsset[] myFunc(int a, int b){ ... }
错误是:
Expected member name or ';' after declaration specifiers
我错过了什么?
您不能在 C++ 中返回数组。尝试返回 a std::vector<cAsset>。
std::vector<cAsset>
std::vector<cAsset> myFunc(int a, int b){ std::vector<cAsset> result; result.push_back(cAsset(4,2)); result.push_back(cAsset(a,b)); return result; }