I have just started out in Vala, and I tried to make a simple program that asks two inputs:
Just before compiling, I got this error:
test0.vala:8.5-8.16: error: Access to instance member `test0.test_exec' denied
test_exec(q);
^^^^^^^^^^^ //the entire statement
Compilation failed: 1 error(s), 0 warning(s)
The pastebin for the very simple program is located here.
Here's a snippet:
public static void main(string[] args)
{
stdout.printf("Greetings! How many cycles would you like? INPUT: ");
int q=0;
stdin.scanf("%d", out q);
test_exec(q);
}
public void test_exec(int q)
{
//method code here
}
Can you please enlighten me about what to do, and some tips? Thanks.
You defined test_exec
as an instance (non-static) method. Unlike a static method, an instance method needs to be called on an instance of the given class. However you're trying to call it without such an instance and thus get an error.
So you either need to create an instance of the test0
class and call test_exec
on that (though that would make little sense since test_exec
does not depend on or change any state of the object - as a matter of fact the test0
class does not have any state) or make test_exec
as well as the other methods called by test_exec
static.