我有这个功能:
set<int> Search(const _Type & hayHeap) const {
set<int>myset;
for (vector<typename>::const_iterator i = needle.begin(); i != needle.end(); ++i) {
cout << (*i) << " ";
}
return myset;
};
针的定义如下:vector<string> needle;
现在我需要创建另一个迭代器,它将遍历hayHeap. 但问题是,我不知道它会是什么类型。它也可以是单个string或vectorof <int>/ <string>。所以当有 a 时string,它只迭代一次,如果有一些向量它迭代(myVector.count()-1)-times。如何使这种类型独立的迭代器?