I am having some errors using a vector in my class definitions.
the errors i get are: variable or field `setName' declared void
expected `;' before '(' token
`vector' does not name a type
Can anyone give me an example of what the code is to look like?
Here is an example of what i have currently (only partial code):
What on earth are you trying to do here: vector <string> name(MAX); Are you just trying to correct a vector of type string named name? I hope you aren't trying to put a size limit on vector. The whole point of using a vector is that you can resize it and change its size anytime you want. If you are trying to set a size you should just use an array.
ok so i will take out the (MAX), i thought that was needed to specify my size limit. I am trying to create a vector of type string in a private member variable. And I can't use an array because i am trying to learn how to use vectors.
Oh, if that's the case then all you need is vector<string> name; Also, you can't make a function that returns a type vector. The same way you can't make a function that returns the type array
The vctor class is a tejplated one and you therefore cant return vector. You should do something like return vector<std::string> and also for the functiin argument type. Creating the gector using MAX only creates the vector with MAX initial elements. It does not set any upper limit as vecyors are meant to be dynamic.