I was trying to overload operators in my template class, but compilator show error:
Error C2676 binary '++': 'Iterator' does not define this operator or a conversion to a type acceptable to the predefined operator
I can`t find solution for my problem. This is my class:
#pragma once
template<typename T> class List;
template<typename T>
class Iterator
{
private:
friend class List<T>;
typename List<T> *pointer;
public:
Iterator(List<T>* mPointer)
{
pointer = mPointer;
}
void operator ++ ()
{
if (pointer != NULL)
{
pointer = pointer->next;
}
}
};
And main:
#include "stdafx.h"
#include "Lista.h"
#include <iostream>
using namespace std;
int main()
{
List<int> newList;
int x = 2;
newList.pushBack(x);
Iterator<int> iterator(newList.end());
cout << newList[iterator] << endl;
iterator++;
cin.get();
cin.get();
return 0;
}