GVala added.

This commit is contained in:
Kolan Sh 2012-10-12 20:44:31 +04:00
parent 58e2f0122c
commit fd13b54b6a
1 changed files with 27 additions and 10 deletions

View File

@ -1,28 +1,45 @@
class Base : GLib.Object {
public virtual void copy () {
stdout.printf ("Base copy() called\n");
public int b;
public virtual void copy_from (Base b) {
stdout.printf ("Base copy_from() called\n");
this.b = b.b;
}
}
class Sub : Base {
public override void copy () {
stdout.printf ("Sub copy() called\n");
public int s;
public override void copy_from (Base b) {
stdout.printf ("Sub copy_from() called\n");
this.s = ((Sub)b).s;
}
}
class SubSub : Sub {
public override void copy () {
stdout.printf ("SubSub copy() called\n");
public int ss;
public int s;
public override void copy_from (Base b) {
stdout.printf ("SubSub copy_from() called\n");
this.ss = ((SubSub)b).ss;
//((Sub)this).copy_from(b);
}
}
class GVala : GLib.Object {
public static int main (string[] args) {
// var base = new Base();
// var sub = new Sub();
Base b = new SubSub();
var src = new SubSub();
src.b = 1;
src.s = 2;
src.ss = 3;
b.copy();
Base b = new SubSub();
b.copy_from(src);
var ss = (SubSub) b;
stdout.printf ("b = %d, s = %d, ss = %d\n", ss.b, ss.s, ss.ss);
return 0;
}