D Paste by Anonymous
Description: None
Hide line numbers

Create new paste
Post a reply
View replies

Paste:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
import std.c.stdio;
import std.stdio;
 interface  a{
 int c();
 }

void main()
{
 class b:a{
 int c(){writefln("b.c");return 1;}
 }
 class c:b{
 int c(){writefln("c.c");return 1;}
 }
 class f:b{
 int k(){writefln("f.k");return 1;}
 }
 interface u:c,f,a{
 int c();
 int k();
 }
 class d:u
 {
  int c(){writefln("d.c");return 2;}
  int k(){writefln("d.k");return 2;}
 }
 d a= new d;
 c v= cast(c)a;
 f newf=cast(f)a;
 a.k();   //prints d.k
 newf.k(); //access violation
 v.c();  //access violation
}

Replies:
No replies posted yet