'T' is not a valid template argument for parameter 'Derived'

97 views Asked by At

I am trying to declare a iterator class within an array class and then implement it outside the array class. However, I am encountering a syntax error. I am not sure why this is not working. I have only been able to deduce that the problem is with my attempt to implement my array iterator. I have labeled the line of the given error below. Ask if you need any other code to be posted or some sort of explanation, I removed a lot of code to prevent posting a mess.

EDIT: I replaced the wrong header with the correct header. I had received different errors which I fixed by placing typename keyword. Is it possible for someone to explain why the typename keyword was my iterator classes implementation? The error I received without it was

std_bidirectional_iterator: ds::Array::iterator is not a valid template argument for parameter derived.

Array.h

#include "Common.h"
#include "ArrayInterface.h"
#include "std_bidirectional_iterator.h"

template<class T, size_t N>
class ds::ArrayTwo : public ArrayInterface<T>
{
    class iterator; // Tried with all following implementations
    template<class T> class reverse_iterator;

    template<class U> class const_iterator;
    template<class T> class const_reverse_iterator;
};

template<class T, size_t N>
// Error on line below[fixed by typename]
class ds::ArrayTwo<T, N>::iterator : public std_bidirectional_iterator<typename ds::ArrayTwo<T, N>::iterator, T>
{
};

std_bidirectional_iterator.h

#include <iterator>

template<class Derived, class Type>
class std_bidirectional_iterator : public std::iterator<std::bidirectional_iterator_tag, Type>
{
    virtual Derived & operator=(const Derived & it) = 0;            // Copy Assignment Operator

    virtual reference operator*(void) = 0;                          // De-Reference Operator (Returns reference)

    virtual pointer operator->(void) = 0;                           // De-Reference Operator (Returns pointer)

    virtual Derived & operator++(void) = 0;                         // Pre-Fix ++
    virtual Derived operator++(int) = 0;                            // Post-Fix ++

    virtual Derived & operator--(void) = 0;                         // Pre-Fix --
    virtual Derived operator--(int) = 0;                            // Post-Fix --

    virtual bool operator==(const Derived & it) const = 0;          // Equal To Operator
    virtual bool operator!=(const Derived & it) const = 0;          // Not Equal To Operator
};
0

There are 0 answers