OOP - Como fazer?
04/06/2008
0
Paulo
Posts
04/06/2008
Brunodsr
Já passei por um problema parecido, mas eu estava usando Strings.
Espero ter ajudado.
04/06/2008
Emerson Nascimento
05/06/2008
Cicero-padim
são eles
constructor Create;
destructor Destroy;
Os métodos para inicialização e finalização da classe tente eles
Há e não esqueça de inicializar as varieveis private;
Cícero;
05/06/2008
Emerson Nascimento
veja o exemplo:
unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TCalculadora = class private FOp1, FOp2: integer; procedure SetOp1(Value: integer); procedure SetOp2(Value: integer); function GetOp1: integer; function GetOp2: integer; public property Op1: integer read GetOp1 write SetOp1; property Op2: integer read GetOp2 write SetOp2; function Soma: integer; overload; function Soma(Valor1, Valor2: integer): integer; overload; function Resta: integer; end; implementation { TCalculadora } function TCalculadora.GetOp1: integer; begin Result := FOp1; end; function TCalculadora.GetOp2: integer; begin Result := FOp2; end; function TCalculadora.Resta: integer; begin end; procedure TCalculadora.SetOp1(Value: integer); begin if Value <> FOp1 then FOp1 := Value; // era: Op1 := Value; end; procedure TCalculadora.SetOp2(Value: integer); begin if Value <> FOp2 then FOp2 := Value; // era: Op2 := Value; end; function TCalculadora.Soma: integer; begin result := FOp1 + FOp2; end; function TCalculadora.Soma(Valor1, Valor2: integer): integer; begin result := Valor1 + Valor2; end;
Clique aqui para fazer login e interagir na Comunidade :)