Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   access private procedures (https://www.delphipraxis.net/175816-access-private-procedures.html)

question 21. Jul 2013 20:06

access private procedures
 
Hello,
I have created a projectgroup , in this projectgroup- i have two units. I have created one procedure in unit under private declaration and I would like to call this procedure from another unit. But I have an error “cannot access private symbol…”
Could you please tell me, how to access private Procedures/Function from one unit to another ?
Here is the code:

unit CalCulation;
interface
uses
type
TCal = class(TObject)
private
procedure AddNumbers (Sender : TObject);
end;
var
MyAdd : TCal;
implementation
procedure TCal. AddNumbers (Sender : TObject);
var
t,o, Result : integer;
begin
//calculation
end;
------------------------------
unit frmShow;

procedure TForm3.Button1Click(Sender: TObject);
begin
MyAdd.AddPublic(Sender); // here is the error as it has declared as a private in other unit
end;

Union 21. Jul 2013 20:17

AW: access private procedures
 
Make them public. AND TAG YOUR SOURCE.

Der schöne Günther 21. Jul 2013 21:10

AW: access private procedures
 
Why did you make it private then? Private means private.

There is, however, a rather ugly way: You can declare a new subclass in your new unit and cast your object to that new subclass.


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:37 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz