调用向量内对象的成员函数
这是我之前关于检索和编辑向量中对象的私有成员。
我有一个充满对象的向量,这些对象具有我需要访问的私有成员。 我已经创建了用于返回每个私有成员的访问器函数,现在正在寻找迭代对象向量的最佳方法,从中返回特定的私有成员并将其与给定变量进行比较,直到找到匹配项。< /strong>
我曾考虑过使用 find_if
但没有成功地为向量中的每个对象使用成员函数返回值作为标准。
我也无法使用 for_each
来完成这项工作。
我创建一个附加问题的原因是我已经在这个问题上停留的时间比我应该的要长,而且我找到问题的解决方案变得非常紧迫。任何朝着正确方向的推动将不胜感激!
This is a continuation on my previous question here regarding retrieving and editing private members of objects in a vector.
I have a vector full of objects that have private members that I need to access. I have created accessor functions for returning each private member and am now looking for the best way to iterate through the vector of objects, returning a specific private member from it and comparing it to a given variable until a match is found.
I have considered using find_if
but have had no luck with using a member functions return value, for each object in the vector, as criteria.
Neither have I been able to use for_each
to do the job.
The reason I am creating an additional question is that I've been dwelling for this longer than I should and it's getting to become quite urgent that I find a solution to the problem. Any nudge in the right direction would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建一个函子:
可以将其放入
find_if
中。Create a functor:
that can be put into the
find_if
.