我正在创建一个字符串类(项目学校),我一直到最后为它创建迭代器,所以我的问题是我不知道从哪里开始我认为开始和结束但它们是如何实现的。这是到目前为止的代码:
class StringsTest {
public:
std::tr1::shared_ptr<char* > word;
char* data;
int size;
int final;
int itSize;
StringsTest();
StringsTest(const StringsTest& orig);
virtual ~StringsTest();
StringsTest(char* strings);
StringsTest& swap( StringsTest& str2 );
int push_back(char a);
char pop_back();
int insert(int where, char what);
int erase(int where);
friend void operator<<(std::ostream& Ostr, const StringsTest& st);
friend std::istream& operator>>(std::istream& Istr, StringsTest& st);
char &operator[](int i);
int sizes();
int check();
stringIte& begin();
stringIte& end();
private:
protected:
};
#endif /* STRINGPROJ_H *
//#endif /* STRINGSTEST_H */
class stringIte {
public:
stringIte();
~stringIte();
和开始:
stringIte& StringsTest::begin() {
try {
} catch (std::exception e) {
std::cout << " an error has ocurred " << e.what() << std::endl;
}
}
stringIte& StringsTest::end() {
try {
} catch (std::exception e) {
std::cout << "nope " << e.what() << std::endl;
}
}
我有这个类我如何实现迭代器开始()。谢谢。