[Vala] instantiation via base class constructor



Hello,

i am new to Vala, played with it the last two days and have now a bunch of open questions.
Here's one of them: Is it possible to instantiate a class via a constructor of one of its base classes? For example the following does not work:

class Aaa {
        public int x;
        Aaa(int x) { this.x = x; }
        public virtual void test() { stdout.printf("%d\n", this.x); }
}

class Bbb : Aaa {
        public override void test() { stdout.printf("%d\n", -this.x); }
}

void main() {
        new Bbb(5).test();
}

$ valac super.vala
super.vala:13.2-13.11: error: Too many arguments, method `Bbb.new' does not take 1 arguments
        new Bbb(5).test();
        ^^^^^^^^^^
Compilation failed: 1 error(s), 0 warning(s)

Thanks in advance!
Andre



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]