Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

root/run/opIdentity_01.d

Revision 1384:d3a3e0c251d8, 0.7 kB (checked in by thomask, 18 years ago)

nntp: -> http:

Line 
1 // $HeadURL$
2 // $Date$
3 // $Author$
4
5 // @author@ teqDruid <me@teqdruid.com>
6 // @date@   2005-01-12
7 // @uri@    news:pan.2005.01.12.13.20.54.546749@teqdruid.com
8 // @uri@    http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D.bugs&artnum=2676
9
10 module dstress.run.opIdentity_01;
11
12 interface I {
13     I parent();
14     void parent(I i);
15     void addChild(I i);
16 }
17
18 interface J : I {
19 }
20
21 class A : I {
22     private I myParent;
23    
24     void addChild(I i) {
25         i.parent = this;
26         }
27
28     I parent() {
29         return myParent;
30     }
31        
32     void parent(I parent) {
33         myParent = parent;
34     }
35 }
36
37 class B : A, J {
38 }
39
40 int main() {
41     J a = new B;
42     J b = new B;
43     a.addChild(b);
44     if(!(b.parent is a)){
45         assert(0);
46     }
47     return 0;
48 }
Note: See TracBrowser for help on using the browser.