template class method with default params

Discussion in 'C++' started by Christopher, Apr 9, 2008.

  1. Christopher

    Christopher Guest

    I can't seem to make my compiler happy. Is it possible to have a
    template class method that takes a default parameter?

    Can that default value be set to a value returned by another method in
    the same class?

    Can that value type be a template class itself?

    current code (snipped irrelevant code):

    template <class T>
    class GenericTree
    {
    class GenericTreeNode
    {
    };

    public:

    class Iterator_BreadthFirst
    {
    GenericTreeNode * m_node;

    public:
    Iterator_BreadthFirst(GenericTreeNode * node);
    Iterator_BreadthFirst(const Iterator_BreadthFirst & rhs);
    };

    Iterator_BreadthFirst begin();

    Iterator_BreadthFirst GetFirstOfDepth(int depth,
    GenericTree<T>::Iterator_BreadthFirst start = begin());
    };

    template <class T>
    typename GenericTree<T>::Iterator_BreadthFirst
    GenericTree<T>::begin()
    {
    return Iterator_BreadthFirst(m_root);
    }

    template <class T>
    typename GenericTree<T>::Iterator_BreadthFirst
    GenericTree<T>::GetFirstOfDepth(
    int depth, GenericTree<T>::Iterator_BreadthFirst start)
    {
    return Iterator_BreadthFirst(0);
    }
     
    Christopher, Apr 9, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Samee Zahur
    Replies:
    1
    Views:
    359
    Victor Bazarov
    Apr 29, 2005
  2. christopher diggins
    Replies:
    16
    Views:
    769
    Pete Becker
    May 4, 2005
  3. Siegfried Heintze
    Replies:
    2
    Views:
    326
    Siegfried Heintze
    Feb 2, 2006
  4. A L
    Replies:
    1
    Views:
    516
    Alf P. Steinbach /Usenet
    Aug 25, 2010
  5. Barry
    Replies:
    9
    Views:
    470
    Ara.T.Howard
    Sep 15, 2005
Loading...

Share This Page