typedef template

0

mam sobie klasę A:

class A {/* ... */};

oraz w innym pliku:

class A ;

typedef std::set<A*> SetOfA ;
typedef SetOfA::iterator SetOfAIterator ;

spoko.

chciałem dodać klasę, a właściwie szablon:

template <class TX, class TZ>
class B {/* ... */};

spoko.

chciałem zrobić analogiczne typedefy w tamtym pliku.

próbowałem różnie:

template <class TX, class TZ>
class B;

template<class TX, class TZ>
typedef std::set<B<TX, TZ>*> SetOfB ;
typedef SetOfB::iterator SetOfBIterator ;

i nie potrafię. najczęściej pojawia się:
error: template declaration of ‘typedef’

jak to zrobić poprawnie?

0

próbowałem też na chama:

template <class TX, TZ>
class B
{
/* ... */
    std::set<B<TX, TZ>*> setOfOther ; //linijka 100
    std::set<B<TX, TZ>*> :: iterator setOfOtherIterator ; //linijka 101
};

tu mi kompilator zwraca błąd:

B.h:101: error: type ‘std::set<B<TX, TZ>*, std::less<B<TX, TZ>*>, std::allocator<B<TX, TZ>*> >’ is not derived from type ‘B<TX, TZ>’
B.h:101: error: expected ‘;’ before ‘setOfOtherIterator’

wtf?

0

ok, sam znalazłem:

template <class TX, class TZ>
class B
{
/* ... */
    
		typedef std::set<B<TX, TZ>*> SetOfB;
		typedef typename SetOfB::iterator SetOfBIterator ;
		SetOfB others ;
		SetOfBIterator othersIterator ;
};

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