I was writing a templated version of the quicksort algorithm for various Containers utilizing iterators, but the following errors made themselves known when I attempted to construct an Object::iterator.
error C2061 : syntax error : identifier 'iterator'
error C2780: 'void myQuickSort(Container &)' : expects 1 arguments - 3 (I believe this error is a result of error C2061)
How can I create an iterator to my templated class Container without the compiler giving me these errors.
My code is written below:
#include<iostream>
#include<vector>
#include<stack>
#include<list>
#include<algorithm>
template<class Itr2Printable>
void printVec(Itr2Printable begin, Itr2Printable end)
{
// couts containing Objecorder
std::cout << "[ ";
for (begin; begin != end; ++begin)
std::cout << *begin << " ";
std::cout << "]";
}
template<class Container>
void myQuickSort(Container& c, Container::iterator begin, Container::iterator end)
{
Container::iterator mid = begin + distance(begin, end) / 2;
// inclomplete
}
int main()
{
std::vector<int> vec{ 15, 75, 50, 0, 100, 5 };
std::cout << "\n\n\tquickSort(";
printVec(vec.begin(), vec.end());
std::cout << ", " << 0 << ", " << vec.size() - 1 << ")\n";
myQuickSort(vec, vec.begin(), vec.end());
}