Error creating a size for a vector of Structs C++

后端 未结 3 1953
走了就别回头了
走了就别回头了 2021-01-26 02:31

This is for a project I am doing for my college class and I could not find an answer for this that worked for me anywhere. Its very likely I did not understand the answers thou

3条回答
  •  萌比男神i
    2021-01-26 03:08

    You're trying to pass parameters to a constructor of a non-static class member as part of the declaration, which is wrong.

    Basically, you'll have to declare the data member in the declaration like this:

    std::vector mi;
    

    and as part of the constructor, call the appropriate resize, if that is even necessary.

    Unless you know you need a minimum vector size of 20, I would forget about pre-sizing it and just let it grow as necessary.

提交回复
热议问题