Considering the vector is to hold a user-type of "TaxPayer". It'd be a fair assumption that he wanted it as a class member. |
How come? Having a global vector of objects or a vector of objects class member both make as much sense to me.
Pat: You know, I'm only trying to help. If my suggestion was irrelevant you don't need to say so. It's your own fault for not giving such important details as the scope of the vector or what the error was.
<rant>Now that I think about it, a lot of people these days like to say "an error". Are we supposed to deduce what the error is, or use some kind of unholy divination technique, or something? Seriously, is it
so hard to write down the specific error before posting? Jesus Christ.</rant>
Leaving that aside, is that misplaced underscore a typo when you posted, or is it in the source, too? My guess is that this is want you want to do:
1 2 3 4
|
A::A():
_taxpayers(20){
//...
}
|
Other than, your only other choice is this:
1 2 3 4
|
A::A(){
_taxpayers.resize(20)
//...
}
|
Note that if TaxPayer doesn't have a constructor that takes no parameters, any of these will fail.