我是C++编程的新手,我需要创建迭代器,但我遇到了循环问题(在C++ 11中),因为它无法识别元素我解释一下:在我自己的类中创建迭代器C++ 11
class myclass{
std::string str;
myclass();
std::iterator<(what do i have to put here?), char, diffptr_t, char*, char&> begin(){
return str.begin();
}
}
此,读取类中的方法:
void func(myclass& m){
for(char a: m){ //Here's the problem, i don't know why it doesn't work
//do function
}
任何机构可以告诉这是最好的方法做到这一点?这里有什么问题?
就像一个音符,的std :: iterator是帮助不实现迭代器实际使用的迭代器的类型。 – Jake