[Vala] Static property
- From: gege2061 <gege2061 redaction-developpez com>
- To: vala-list gnome org
- Subject: [Vala] Static property
- Date: Tue, 22 Jan 2008 21:33:21 +0100
Hi,
I wan't implement singleton pattern but I have compilation error :
using GLib;
public class Singleton : Object
{
static Singleton* _instance = null;
private Singleton ()
{
}
public static Singleton* instance
{
get
{
if (_instance == null)
{
_instance = new Singleton ();
}
return _instance;
}
}
public static Singleton* get_instance ()
{
if (_instance == null)
{
_instance = new Singleton ();
}
return _instance;
}
public static int main (string[] args)
{
Singleton* s = null;
s = Singleton.get_instance ();
s = Singleton.instance; // line 35
return 0;
}
}
And compilation command :
$ valac singleton.vala
/home/gege2061/test/vala/singleton.vala:35.7-35.7: error: Assignment: Invalid callback assignment attempt
Compilation failed: 1 error(s), 0 warning(s)
I don't undestand my error :(
--
Nicolas Joseph
Responsable de la rubrique GTK+ de
developpez.com
http://nicolasj.developpez.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]