[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ProgSoc] Re: Delphi: Exposing properties of private members
As far as I know, you can't do what you want to do.
The read/write methods of a property must specify a field/method that
belongs to the immediate class. You'll have to write pass-through
functions.
That's what I think anyway...
Cheers,
Jay.
On Sun, 17 Jun 2001, 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:
>
> //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-//
> type
> TOrc = class(TObject)
> private
> FSocket: TClientSocket;
>
> public
> property Host: string read blah write blah;
> property Port: Integer read blah write blah;
> end;
> //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-//
>
> .. 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.
>
> i.e.
>
> property Host: string read FSocket.Host write FSocket.Host;
>
> .. but that doesn't work.
>
> Any ideas?
>
> gleNN
>
>
-
You are subscribed to the progsoc mailing list. To unsubscribe, send a
message containing "unsubscribe" to progsoc-request@nospam.progsoc.uts.edu.au.
If you are having trouble, ask owner-progsoc@nospam.progsoc.uts.edu.au for help.