Skip to main content
gamedev.net
🔒 Locked

Template Question

Started by nolongerhere 0 replies 750+ views
Original Post
nolongerhere
nolongerhere
Ive never used C++'s templates much but I was messing with them the other day and found this not to work:

template <class P>
stack<P> bleh;
Im curious to why it doesnt work, any ideas? Im sure its a simple problem, but im not familar with this aspect of C++. Thanks
jflanglois
jflanglois
Well, what are you trying to do? Are you trying to create an instance of the standard stack type? If that's the case, then you don't need the template part:
std::stack< int > st; (a stack of ints)

Are you trying to create your own templated stack type? If so:
template< class T >
class stack {
// implement stack based on type T
};


In any case, you are going to have to tell us more about what you are trying to do.


jfl.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.