Board index » delphi » Looking for equivalent to 'friend'(C++) in object pascal

Looking for equivalent to 'friend'(C++) in object pascal

I was wondering if there is function in Turbo Pascal that is equivalent
to the 'friend' function in C++? (This being a way of one object being
able to look at another object's private members.)

Thanks alot,
Shona Suderman

--
| Shona Suderman            |                                      |
| Computer Engineering      |   "If you want to make God laugh,    |
| University of Manitoba    |      just tell Him your plans."      |
| umsud...@cc.umanitoba.ca  |                                      |

 

Re:Looking for equivalent to 'friend'(C++) in object pascal


On 16 Jan 1996, Shona Gail Suderman wrote:

Quote
> I was wondering if there is function in Turbo Pascal that is equivalent
> to the 'friend' function in C++? (This being a way of one object being
> able to look at another object's private members.)

Nope.  Never had it, and (seeing as how it looks like the last release of
Turbo Pascal is already out) it probably never will.  There are a few
tricks on how to duplicate the idea, but they don't work all that well
and I bet you've already thought of them.  Sorry.  (Look on the bright
side--there is less to learn about Pascal!)

=============================================================
Douglas Cook, undergraduate in Computer Science at BYU
-------------------------------------------------------------
*REAL* programmers use COPY CON PROGRAM.EXE
=============================================================

Re:Looking for equivalent to 'friend'(C++) in object pascal


Douglas Evan Cook <co...@cs.byu.edu> wrote:

Quote
>On 16 Jan 1996, Shona Gail Suderman wrote:

>> I was wondering if there is function in Turbo Pascal that is equivalent
>> to the 'friend' function in C++? (This being a way of one object being
>> able to look at another object's private members.)

>Nope.  Never had it, and (seeing as how it looks like the last release of
>Turbo Pascal is already out) it probably never will.  There are a few
>tricks on how to duplicate the idea, but they don't work all that well
>and I bet you've already thought of them.  Sorry.  (Look on the bright
>side--there is less to learn about Pascal!)

That's true, but not the whole story.  There is a way for one object
being able to look at another object's private members.  Just declare
them in the same unit.  The scoping rules say that all fields and
methods, private or not, are visible in the unit.  Private only hides
things from other units.

If you're stuck with a unit where something is declared private and
you need access to it from outside the unit, then you should redeclare
that thing as public.  If you can't recompile, then it's not hard to
patch the .TPU file to change the "private" bit; take a look at
INTRFC70.ZIP (available lots of places, including garbo.uwasa.fi) for
the TPU format.

Duncan Murdoch

Re:Looking for equivalent to 'friend'(C++) in object pascal


On Tue, 16 Jan 1996 00:33:15 -0700, Douglas Evan Cook

Quote
<co...@cs.byu.edu> wrote:
>On 16 Jan 1996, Shona Gail Suderman wrote:

>> I was wondering if there is function in Turbo Pascal that is equivalent
>> to the 'friend' function in C++? (This being a way of one object being
>> able to look at another object's private members.)

>Nope.  Never had it, and (seeing as how it looks like the last release of
>Turbo Pascal is already out) it probably never will.  There are a few
>tricks on how to duplicate the idea, but they don't work all that well
>and I bet you've already thought of them.  Sorry.  (Look on the bright
>side--there is less to learn about Pascal!)

>=============================================================
>Douglas Cook, undergraduate in Computer Science at BYU
>-------------------------------------------------------------
>*REAL* programmers use COPY CON PROGRAM.EXE
>=============================================================

         Stefan Benzinger
Ispergasse 28      Regerstr. 1
1210 Wien          84489 Burghausen
0222/2925035       Deutschland 08677/3954

h8950...@falbala.wu-wien.ac.at
WWW: http://www.wu-wien.ac.at/usr/h89/h8950427/
                              Red Alert, Fire Phasers

Other Threads