A class example


    class IntegerStack
    {
	private:
	   buffer: int[];
	   stack_size: int;
	   stack_top_index: int;
	public:
	   function push (new_item: int)
	   {	if (stack_top_index < stack_size)
		   buffer[++stack_top_index]:=new_item;
	   }
	   function pop ():int
	   {	if (stack_top_index >=0)
		   return buffer[stack_top_index--];
		return 0;
	   }
	   enter (size: int) 	// constructor
	   {    if (size<100) size:=100;
		buffer := int[size]();
		stack_size := size;
		stack_top_index := -1;
	   };
    };

For examples using the class, click here.




[ Go back to tutorial | Tutorial home page | Transframe home page ]

More examples: