Reputation: 107
I have a class that looks like this:
template <typename P>
class Pack {
Public:
template <typename X>
Private:
Other T <other>
};
I want to write the function outside of the class but I am having difficulties defining the header.. I tried something like this:
template <typename X>
int Pack<X>::pop(X led) const{
// Do something in here with Other from the private above
}
But this does not work it keeps saying "Out of line definition of pop, does not match any definitions of P.
Any help is appreciated thanks!
Clarification: Trying to Implement the function stub so I can write the code outside of the class.
Upvotes: 1
Views: 762
Reputation: 43662
Your code looks incomplete and you're posting small chunks of it from time to time but I believe this syntax is what you want:
#include <iostream>
using namespace std;
template <typename P>
class Stack {
public:
template <typename X> int pop(X pred) const;
};
template <typename P>
template<typename X>
int Stack<P>::pop(X pred) const{
return 0;
}
int main() {
Stack<bool> obj;
char a;
obj.pop(a);
return 0;
}
Upvotes: 5