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

Down

Circular class reference Find similar branches


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

Such a problem
T1 = class
F: T2;
end;
T2 = class
F: T1;
end;
so solved
T2 = class;
T1 = class
F: T2;
end;
T2 = class
F: T1;
end;
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];

Top









Memory: 0.57 MB
Time: 0.024 c
1-22171
Sun
2001-12-20 14:19
2002.01.08
Is a miracle possible?


1-22262
Kate
2001-12-17 15:25
2002.01.08
help


3-21929
@andrew
2001-12-04 11:38
2002.01.08
HELLO! I make a journal. Where did the task ....


14-22338
Dima-k17
2001-11-05 10:57
2002.01.08
Os petros


3-21982
Dush
2001-12-06 12:37
2002.01.08
Client connection to the database





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 Español 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
zulu
English French German Italian Portuguese Russian Spanish