Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 01-03-2001, 09:36 AM
gggreen69 gggreen69 is offline
Junior Member
 
Join Date: Jan 2001
Posts: 19
Default friends in Delphi ?? (or other access workarounds)

If you know C++ you know that a function prototyped in the host class preceded by the keyword 'friend' will have access to all the private and protected members of the host class.
Is there an equivalent cheat in Delphi? Or another way to accomplish this sort of thing? I have looked but havent found anything yet.
Thanks, and yes I know 'friends are bad' as my C++ prof used to say

Seth (new to Delphi)
Reply With Quote
  #2  
Old 01-03-2001, 10:31 AM
Claude Claude is offline
Senior Member
 
Join Date: Jan 2001
Posts: 178
Default RE: friends in Delphi ?? (or other access workarounds)

Delphi lacks some C++ features. neither "Friends", nor Operator overloading are supported.
Reply With Quote
  #3  
Old 01-04-2001, 08:08 AM
hbah245 hbah245 is offline
Junior Member
 
Join Date: Jan 2001
Posts: 13
Default RE: friends in Delphi ?? (or other access workarounds)

One of the quirks of Delphi is that classes in the same unit can access protected and private methods and variables. Borland does this a lot in their VCL component libraries. I have declared a class in an existing VCL to access private parts but I do not recommend this. Every time you upgrade you Delphi, you need to upgrade you class on the new VCL. I would hope that Borland would add a “Friend” identifier, but I don’t think they will. Also, you might try using to old “Hack” trick. Declare a class in you unit derived from the class you want to get the protected ???? from :

THackClass = class(DBGrid);

In your program cast you "Hack Class" like this:

with THackDBGrid(DBGrid1).Canvas do
………..
end;
This will get you the protected canvas object. I don’t know if it will work for private parts.

There are some good examples of this out there if you want more information..
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 05:16 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.