简体   繁体   English

C ++中的通用迭代器

[英]Generic iterator in c++

I am busy with a project and want to know what is Generic iterator class for arrays of type T and how do i write one. 我正在忙一个项目,想知道什么是type T数组的通用迭代器类,以及如何编写一个。 I have look in books and on websites and i cant find anything on it. 我在书籍和网站上看过,但找不到任何东西。 Please help. 请帮忙。 But dont write code for me. 但是不要为我写代码。

Probably a class that has operators unary * , ++ and possibly -- defined, where the first one returns a reference to the underlying T object, the second advances the iterator to the next element in the container and the last one advances the iterator backwards. 可能是一个具有一元运算符*++的类,并且可能定义了-- ,其中第一个返回对基础T对象的引用,第二个将迭代器前进到容器中的下一个元素,最后一个将迭代器后退。

Or, if you're using some standard container, just the return value of yourContainer.begin() or yourContainer.find() . 或者,如果您使用的是标准容器,则仅返回yourContainer.begin()yourContainer.find()的返回值。

If you elaborate on your question you can get a better answer. 如果您详细说明问题,则可以获得更好的答案。 For example, what container are you using? 例如,您使用的是哪个容器? What's expecting a generic iterator? 对通用迭代器有什么期望?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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