[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ProgSoc] Delphi: Exposing properties of private members
Glenn Williamson wrote:
> Hey All,
> I'm writing a class which (among other things) maintains a TCP/IP
> connection to a server machine. Like so:
> TOrc = class(TObject)
> FSocket: TClientSocket;
> property Host: string read blah write blah;
> property Port: Integer read blah write blah;
> .. where the public Host property maps directly to the FSocket.Host
> property, and likewise for the Port property. I was wondering if there was
> a way to directly expose these as public properties rather than having to
> write GetHost, SetHost, GetPort and SetPort routines.
> property Host: string read FSocket.Host write FSocket.Host;
> .. but that doesn't work.
I remember doing something of the sort where u could make a property
which calls a function when it is written to, and another when it is
so something like:
procedure setHost(Value: string);
property Host: string read getHost write setHost;
procedure classtype.setHost(Value: string);
sure, this involves write a set??? procedure, but its not that much
work. Actually, thats probably what u didn't want to do.
from the manual (delphi 4), the access specifier (the name after the
read or write statement) is ``the name of a field or method declared in
the same class as the property or in an ancestor class''. So from this,
I would assume u would either have to write functions as mentioned, or
inherit the TClientSocket class (which may be a better way to do it
anyway - inheritance is ur friend)
hope this make a bit of sense and helps.
If you think education is expensive, try ignorance.
-- Derek Bok, president of Harvard
You are subscribed to the progsoc mailing list. To unsubscribe, send a
message containing "unsubscribe" to email@example.com.
If you are having trouble, ask firstname.lastname@example.org for help.