errors with C ++ models from GCC to Visual C ++


The following compiles in GCC:


template <class T>
class cvec : public deque<T>
   class deque<T>::iterator Find(T);


template <class T>
class deque<T>::iterator cvec<T>::Find(T element)


In Visual C++, get:

error C2242 "typedef name cannot follow class/struct/union.

I changed "class" in the header file to "typename", but receive error C3860 - template argument list must list parameters in the order used in the template param list. There is only one parameter in this case, T. Unless the compiler is confused about Find(T element)?

What is this supposed to mean in the header:

class deque<T>::iterator Find(T);

You are not declaring a class. The typename keyword would be valid here, but class makes no sense.

And the same is true in the .cpp file:

template <class T>
typename deque<T>::iterator cvec<T>::Find(T element)

is correct, class isn't.

Apart from this, it really looks like what you're trying to do is a horrible idea. std::deque already has a find function. It works. It is correct. It is efficient. There is no need to reinvent it.

The standard library containers are also not designed to be derived from. They don't have virtual destructors.

All you're achieving (apart from the compile errors) is that you're going to end up with a buggy, less efficient container class that'll confuse other C++ programmers because it doesn't use the idiomatic interface.