Problem z iteratorami i szablonami

0

Mam taki oto plik h

#ifndef DYNAMICMATRIX_H
#define DYNAMICMATRIX_H

#include <list>

#ifdef WINAPI_POINT_ENABLED

#define WIN32_MEAN_AND_LEAN
#include <windows.h>

#endif

using namespace std;

template <class TYPE>
class DYNAMICMATRIX
{
    public:
         DYNAMICMATRIX(){}
         ~DYNAMICMATRIX();
         TYPE& operator()(int, int);
         bool Add(int, int, TYPE);  
         bool Delete(int, int);
         bool Fill(TYPE);
         
         #ifdef WINAPI_POINT_ENABLED
         
         TYPE& operator()(POINT);
         bool Add(POINT, TYPE);  
         bool Delete(POINT);
         
         #endif
         
    private:
         typedef list< list<TYPE>* > LISTX;
         typedef list<TYPE> LISTY;
         typedef list< list<TYPE>* >::iterator ITERATORX; //<- !!!
         typedef list<TYPE>::iterator ITERATORY; //<- !!!
         
         LISTX Matrix;
         TYPE EmptyField;
         
         bool Exist(int, int);
         bool MoveIterator(ITERATORX&, int);
         bool MoveIterator(ITERATORY&, int);
         ITERATORX FindPlace(LISTX&, int); 
         ITERATORY FindPlace(LISTY&, int);
         bool CmpX(TYPE, TYPE);
         bool CmpY(TYPE, TYPE);
};

#endif

Do tego jeszcze na razie pusty plik .cpp z deklaracjami funkcji.
Dev wyrzuca mi takie oto błędy:

DYNAMICMATRIX.h:37: error: type `std::list<std::list<TYPE, std::allocator<_CharT> >*, std::allocator<std::list<TYPE, std::allocator<_CharT> >*> >' is not derived from type `DYNAMICMATRIX<TYPE>'
DYNAMICMATRIX.h:37: error: ISO C++ forbids declaration of `iterator' with no type
DYNAMICMATRIX.h:37: error: expected `;' before "ITERATORX"
DYNAMICMATRIX.h:38: error: type `std::list<TYPE, std::allocator<_CharT> >' is not derived from type DYNAMICMATRIX<TYPE>'

DYNAMICMATRIX.h:38: error: ISO C++ forbids declaration of `iterator' with no type
DYNAMICMATRIX.h:38: error: expected `;' before "ITERATORY"
DYNAMICMATRIX.h:44: error: expected `;' before '(' token
DYNAMICMATRIX.h:45: error: expected `;' before '(' token
DYNAMICMATRIX.h:46: error: `ITERATORX' does not name a type

DYNAMICMATRIX.h:47: error: `ITERATORY' does not name a type

Wiem, że błąd tkwi w tych dwóch instrukcjach typedef. Sprawdzałem jeszcze, czy dla int zamiast TYPE będzie wyrzucał takie same błędy - wszystko skompilowało się bez problemu.
Nie rozumiem, dlaczego wyrzuca mi błędy.
Byłbym wdzięczny, gdyby ktoś mi to wytłumaczył.

0

Zrób z tego typename i naspisz co dostajesz.

0

Dokładnie to samo. Wygląda to tak, jakby iterator musiał znac typ, z jakim będzie pracował... albo błąd tkwi w pierwszeństwie operatorów.

0
typedef typename list< list<TYPE>* >::iterator ITERATORX; //<- !!!
typedef typename list<TYPE>::iterator ITERATORY; //<- !!!

Powinno działać. Gdy odnosisz się do typu zdefiniowanego w innym obiekcie muszisz dać typename.

Pozdrawiam

P.S. zrób jakieś ciało destruktora

1 użytkowników online, w tym zalogowanych: 0, gości: 1