Top.Mail.Ru Yandeks.Metrika
Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];


Circular class reference Find similar branches

oomneeq   (2001-12-14 21:26) [0]

Such a problem
T1 = class
F: T2;
T2 = class
F: T1;
so solved
T2 = class;
T1 = class
F: T2;
T2 = class
F: T1;
Question: Is there a solution for the case when the classes T1 and T2
located in different unit "ah?
I can't do something: <

Иван Шихалев   (2001-12-14 22:03) [1]

Of course not. What for?

You can only declare an ancestor of T2 in scope for T1.

oomneeq   (2001-12-17 12:00) [2]

A question generally not idle.
It would be desirable, that classes had mutual links against each other, but for some reasons cannot be placed in one module - they are TForm.
While I do this through an intermediary - a class that knows both,
and each of them knows him. Through this intermediary, they access each other.
Throw a little idea of ​​direct acquaintance of the above classes.
Well, at least hint where to dig :)

Fellomena   (2001-12-17 12:36) [3]

I can not say exactly how it can be done in Delphi, but in C ++ there is such a thing as friendly classes,
those. classes declared as friendly have access to all fields (methods?) of another class, even those
in Privat section described. I know that in Delphi all classes located in one unit are considered friendly, but here’s how
do the same for different units ???

Иван Шихалев   (2001-12-17 19:17) [4]

The problem is that classes should be described in the section interface (by the way, access to private fields, like b, was not discussed), and circular references in this section are strictly prohibited. The most correct way:

unit Unit1; interface uses ; ; type TForm1 = class (TForm) fldForm2: TForm; procedure doSomeThing; end ; implementation uses Unit2; procedure TForm1.doSomeThing; begin (fldForm2 as TForm2) .TForm2OnlyProperty: = AnyValue; fldForm2.TFormProperty: = AnotherValue end ; end .

And quite similarly - Unit2, only one and two places change places.

Pages: 1 whole branch

Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];


Memory: 0.56 MB
Time: 0.028 c
Victor Tsay
2001-11-08 09:11
How in the Delphi editor to shift blocks of text?

2001-11-01 11:10
COM NetMeeting Objects

2001-12-18 17:19
Question to pascalshchik ???

2001-12-17 15:28
Tell me, is there a DsgnIntf ​​unit in D6?

2001-12-13 23:05
Appearance form

afrikaans albanian Arabic armenian azerbaijani basque belarusian bulgarian catalan Chinese (Simplified) Chinese (Traditional) croatian Czech danish Dutch English estonian filipino finnish French
galician georgian German greek haitian Creole hebrew Hindi hungarian icelandic indonesian Irish italian Japanese Korean latvian lithuanian macedonian malay maltese norwegian
persian polish portuguese Romanian russian serbian slovak Slovenian Spanish swahili Swedish thai turkish Ukrainian urdu vietnamese welsh yiddish bengali bosnian
cebuano Esperanto gujarati hausa hmong igbo javanese kannada khmer lao latin maori marathi mongolian nepali punjabi somali tamil telugu yoruba
English French German Italian Portuguese Russian Spanish