简体   繁体   中英

no match for call to ‘(std::vector<foo>) (std::vector<foo>::iterator&)’

I've got a class foo, and have created a vector for it using this code

std::vector<foo> fooVector;

I also have an iterator using this code

std::vector<foo>::iterator locator;

now I'm getting this error

foo.cpp:29:25: error: no match for call to ‘(std::vector<foo>) (std::vector<foo>::iterator&)’

and the corresponding line is

if(fooVector(locator).getBoo() + (insertBar.geBoo()) < 4000)

as far as I can tell I'm using the iterator correctly?

I'm not sure what is wrong with how I'm using it?

fooVector(locator) what do you want to express by this?

fooVector is a variable not a function.

如果在使用locator器迭代器之前正确对其进行了初始化,则应将代码更改为

if(locator->getBoo() + (insertBar.geBoo()) < 4000)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM