Say I have a template class declared as follows:
template %26lt;class T%26gt;
class whatever {
private:
struct Node {
//...
};
Node* find();
//...
};
I want to implement the find() member function but I don't know how. What I tried doing was as follows:
template %26lt;class T%26gt;
whatever%26lt;T%26gt;::Node whatever%26lt;T%26gt;::find() {
}
But that doesn't work. Do I simply have to implement the function inside the class definition? That apparently works just fine. If that's the case, should I just implement all member functions inside the class definition for stylistic reasons?
How to implement template classes and structs inside classes (C++)?
Ummm... I think that you need to try this outside the class:
template%26lt;class T%26gt;
whatever::Node *find(){
//Your find routine here.
}
You got a little tangled up in the template thing there,
I think. I hope this helps you out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment