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

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,184
Latest member
ZNOChrista

Latest Threads

Top