теперь вот сел за очередь ( та же задача http://forum.pascal.net.ru/index.php?showtopic=13227 ). Скатал готовый пасс ( тк своей башки на написание не хватит ), но как всегда пока переделывал чёто левое наворотил, проверьте пожалста. Я его описал ... uses MyQueue; var l,p,t: TQueue; ... вот так, но при обращении к этим переменным (када точечку ставиш ) пишет чёто типа не могу откомпилировать пас
упс пардон я думал ты сказал дам а не дал кароче чёт сложно для меня ) я вощем такую фигню накатал, вроде катит
Код
unit MyQueue;
interface
type PNode = ^Node; Node = record Info:Char; Next:PNode; end; TQueue = class private head,tail:PNode; public function Empty:Boolean; procedure Push (Value:Char); procedure Pop (var Value:Char); constructor Create; destructor Destroy; override; end;
implementation
constructor TQueue.Create; begin inherited; head:=nil; tail:=nil; end;
destructor TQueue.Destroy; var Value:Char; begin while (not Empty) do Pop (Value); inherited; end;
function TQueue.Empty:Boolean; begin Empty := not assigned(head); end;
procedure TQueue.Push (Value:Char); var P:PNode; begin new(P); p^.info:=value; p^.next:=nil; if empty then head:=p else tail^.next := p; tail:=p; end;
procedure TQueue.Pop (var Value:Char); var P:PNode; begin if not Empty then begin value:=head^.info; p:=head; head:=p^.next; if head=nil then tail:=nil; dispose(p); end; end;