My Property Class:
unit SubImage;
interface
type
TSubImage = class
private
{ private declarations }
function getHeight: Integer;
function getWidth: Integer;
procedure setHeight(const Value: Integer);
procedure setWidth(const Value: Integer);
protected
{ protected declarations }
public
{ public declarations }
property width : Integer read getWidth write setWidth;
property height : Integer read getHeight write setHeight;
published
{ published declarations }
end;
implementation
{ TSubImage }
function TSubImage.getHeight: Integer;
begin
Result:= height;
end;
function TSubImage.getWidth: Integer;
begin
Result:= width;
end;
procedure TSubImage.setHeight(const Value: Integer);
begin
height:= Value;
end;
procedure TSubImage.setWidth(const Value: Integer);
begin
width:= Value;
end;
end.
Assignment:
objSubImg.width:= imgOverview.width;
objSubImg.height:= imgOverview.heigh
Interesting Error:
stackoverflow at xxxxxx
I am learning to properties in Delphi. I created a class, but it gives an error. I couldn't understand, where is my mistake?
Also i dont understand why we use property instead of setter/getter methods. Anyway can someone help me, how can i fix this code ?
I can not set property value.
F7to step into the next procedure that get called. You'll soon notice you keep going into the same method (because you've written an infinite recursion). This is why you run out of stack space and get the error.