Why use property in a class?

Viewed 8466

I was just wondering about why should I use property in a class instead of "normal" variables (class attributes?). What I mean is this:

TSampleClass = class
  public
    SomeInfo: integer;
end;

TPropertyClass = class
  private
    fSomeInfo: integer;
  public
    property SomeInfo: integer read fSomeInfo write fSomeInfo;
end;

What is the big difference? I know that I can define getter and setter methods for getting or saving the property respectively, but that is possible even without the variable being a "property".

I tried searching for why to use it, but nothing useful came up, so I'm asking here.

Thank you

6 Answers
Related