[Mono-list] [newbie] Class resolvement
Dennis Haney
davh@davh.dk
08 Jun 2002 02:38:25 +0200
--=-=-=
I cant make heads or tails of what mcs gives me with this, so could
someone please run it using m$'s compiler?
mcs says:
Super:Super
lvl1 :Super
lvl2 :Super
lvl3 :Super
Super:Super
lvl1 :Super
lvl2 :Super
lvl3 :Super
Super:Super
lvl1 :Super
lvl2 :Super
lvl3 :Super
Super:Super
lvl1 :Super
lvl2 :Super
lvl3 :Super
Super:Super
lvl1 :Super
lvl2 :lvl1
lvl3 :lvl2
Super:Super
lvl1 :Super
lvl2 :Super
lvl3 :Super
Super:Super
lvl1 :Super
lvl2 :lvl2
lvl3 :lvl3
My guess would have been (I did start looking a C# syntax 4 hours ago):
Super:Super
lvl1 :lvl1
lvl2 :lvl2
lvl3 :lvl3
Super:Super
lvl1 :Super
lvl2 :lvl1
lvl3 :lvl2
Super:Super
lvl1 :lvl1
lvl2 :lvl2
lvl3 :lvl3
Super:Super
lvl1 :Super
lvl2 :lvl1
lvl3 :lvl2
Super:Super
lvl1 :lvl1
lvl2 :lvl2
lvl3 :lvl3
Super:Super
lvl1 :Super
lvl2 :lvl1
lvl3 :lvl3
Or something like that...
--
Dennis
use Inline C => qq{void p(char*g){
printf("Just Another %s Hacker\n",g);}};p("Perl");
--=-=-=
Content-Disposition: attachment
using System;
class Main {
public static int Main(string[] args) {
super v0 = new super();
super v1 = new lvl1();
super v2 = new lvl2();
super v3 = new lvl3();
Console.WriteLine("Super:" + v0.i);
Console.WriteLine("lvl1 :" + v1.i);
Console.WriteLine("lvl2 :" + v2.i);
Console.WriteLine("lvl3 :" + v3.i);
Console.WriteLine("Super:" + v0.i);
Console.WriteLine("lvl1 :" + ((super)v1).i);
Console.WriteLine("lvl2 :" + ((lvl1 )v2).i);
Console.WriteLine("lvl3 :" + ((lvl2 )v3).i);
Console.WriteLine("Super:" + v0.I);
Console.WriteLine("lvl1 :" + v1.I);
Console.WriteLine("lvl2 :" + v2.I);
Console.WriteLine("lvl3 :" + v3.I);
Console.WriteLine("Super:" + v0.I);
Console.WriteLine("lvl1 :" + ((super)v1).I);
Console.WriteLine("lvl2 :" + ((lvl1 )v2).I);
Console.WriteLine("lvl3 :" + ((lvl2 )v3).I);
Console.WriteLine("Super:" + v0.I2);
Console.WriteLine("lvl1 :" + v1.I2);
Console.WriteLine("lvl2 :" + v2.I2);
Console.WriteLine("lvl3 :" + v3.I2);
Console.WriteLine("Super:" + v0.I2);
Console.WriteLine("lvl1 :" + ((super)v1).I2);
Console.WriteLine("lvl2 :" + ((lvl1 )v2).I2);
Console.WriteLine("lvl3 :" + ((lvl2 )v3).I2);
return 0;
}
}
class super {
public string I {
get{ return "Super";}
}
public virtual string I2 {
get{ return "Super";}
}
public string i = "Super";
}
class lvl1 : super {
public new string I {
get{ return "lvl1 ";}
}
public new virtual string I2 {
get{ return "lvl1 ";}
}
new string i = "lvl1 ";
}
class lvl2 : lvl1 {
public new string I {
get{ return "lvl2 ";}
}
public override string I2 {
get{ return "lvl2 ";}
}
new string i = "lvl2 ";
}
class lvl3 : lvl2 {
public new string I {
get{ return "lvl3 ";}
}
public sealed override string I2 {
get{ return "lvl3 ";}
}
new string i = "lvl3 ";
}
--=-=-=--