Trying to populate an array using a function in C++ [closed]

痴心易碎 提交于 2019-12-04 21:40:43
int main() {
  planes planesArray[5];
  populate( planesArray); // this is how to call your function
}
^^^
note:  ; disappeared

When you call a function given some parameter you do not mention type of this parameter.

Next, you will try to implement your function. At the moment it does nothing with array parameter, but we won't provide ready tuned-in solution but rather help when you meet some concrete problems.

Arrays are unfit for such a task in C++, especially if you are new to the language. Use std::vector - and rename "planes" to "plane", which makes more sense (your struct represents one plane, not many).

int populate (std::vector<plane> &plane_vector)
{
  // ...
}

int main()
{
  std::vector<plane> plane_vector;
  populate(plane_vector);
}

This should fix the most blatant errors.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!