Class Tempates

Ark Ark_member at pathlink.com
Sun Apr 2 07:52:50 PDT 2006


Hello, 

How do you use template class instance ? 
For instance how do you translate this generic stack template ? 

Thanks,
Ark

-----------------------
template <class T> class Stack 
{
public:
Stack() { top = -1; }
void push(T i)
{ st[++top] = i; }
T pop()
{ return st[top--]; }
private:
int top;
T st[100];
};

int main ()
{
Stack<int> ii;
Stack<string> ss;
ii.push(25);
ss.push("Hello");
}





More information about the Digitalmars-d mailing list