Class Tempates

Frank Benoit benoit__ at __tionex.de
Sun Apr 2 08:16:15 PDT 2006


Haven't compiled it. But should work.

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

int main ( char[][] args)
{
auto ii = new Stack!(int);
auto ss = Stack!(char[]);
ii.push(25);
ss.push("Hello");
return 0;
}



More information about the Digitalmars-d mailing list