typename & inheritance errors also typename & iterator definition errors

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prw8864
    New Member
    • Mar 2010
    • 2

    #1

    typename & inheritance errors also typename & iterator definition errors

    In the following code I am trying to create a new templete class (SVector) that is a linked list with the added functionality of an insert method that automatically places items in sorted order.

    I am having 2 problems 1) in the statement "class SVector:public list<T>" T is not recognized as per the messages:
    svector.c++:21: error: expected template-name before ‘<’ token
    svector.c++:21: error: expected `{' before ‘<’ token
    svector.c++:21: error: expected unqualified-id before ‘<’ token

    2) I can not get the compiler (gcc 4.3.2) to setup typedefs for iterators as per the messages:
    svector.c++:36: error: invalid use of template-name ‘std::iterator’ without an argument list



    [code=c]
    #include <iostream>
    #include <vector>

    using namespace std;

    template <typename T>
    class SVector:public list<T>
    {
    typedef typename list<T>::iterat or iterator;
    typedef typename list<T>::const_ iterator const_iterator;
    SVector() : list<T> v() {}
    ~SVector() { delete v; }
    .
    .
    .

    private:
    iterator bsearch(iterato r, iterator, T)
    iterator isearch(iterato r, iterator, T)
    }

    iterator Svector::isearc h(iterator low, iterator high, Type item)
    {
    iterator P;
    for (p = low; (*p < item) && (p != high); p++;)
    return p;
    }
    [/code]

    Thanks in advance
    Phillip Wyckoff
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    You haven't included <list>

    Comment

    Working...