Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

seeking explanation of code?

Status
Not open for further replies.

delfy

MIS
Feb 8, 2005
96
JM
this is a section of a private section of a class

private
SC : TSQLConnection;
function GetConnStr: widestring;

procedure DatabasesOnServer(Databases : TStrings);

property ConnStr : widestring read GetConnStr;
public

what can somebody explain what does this line do/mean?

"property ConnStr : widestring read GetConnStr;"


the whole thing can be found here :
 
the Delphi help has some good stuff on properties, but to give you a quick summary:

that line adds a read-only property to the class, called ConnStr. There is no functional difference between a read-only property and a function (except when the property is published). When you reference the ConnStr property, you're actually calling the GetConnStr function.

The property is private in this class, but descendant classes may elevate it's visibility like this
Code:
type
  TDescObj = class(TMyClass)
  public
    property ConnStr;
  end;
That would allow instances of TDescObj to refer to ConnStr - note that no other information is required on that property line, it's simply elevating the visibility of the inherited property declaration.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top