Re: [Vala] instantiation via base class constructor

Hi Andre,

You may use base keyword to call the super (derived base class) methods and constructor. I know that did not help, but you may reduce duplicating your code.


On Wed, Dec 24, 2008 at 2:29 PM, Andre Kuehne <andre kuehne gmx net> wrote:

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 `' does not take 1 arguments
       new Bbb(5).test();
Compilation failed: 1 error(s), 0 warning(s)

Thanks in advance!
Vala-list mailing list
Vala-list gnome org

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