template class method with default params

C

Christopher

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);
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top