Article View: es.comp.os.linux.programacion
Article #14505Re: Punteros a funciones en C++
From: migue
Date: Fri, 03 Nov 2000 12:32
Date: Fri, 03 Nov 2000 12:32
55 lines
2797 bytes
2797 bytes
Vladimir wrote: > Mu buenas: > > Estoy intentando compilar un programa del que me he bajado los > fuentes, pero el muy jod�o no se deja. Todos los errores de > compilaci�n que me da son por lo mismo: cuando en alg�n sitio se > intenta llamar a una funci�n que tiene alg�n par�metro que es un > puntero a funci�n. > > Por ejemplo, en un m�dulo (Form.h), donde se declara la clase > TForm, algunos de sus m�todos son: > > void Destroy(); > void AddSignal(GtkSignalFunc Func, char * Event); > > GtkSignalFunc est� definida en los chismes del GTK y es: > > #define GTK_SIGNAL_FUNC(f) ((GtkSignalFunc) f) > > typedef void (*GtkSignalFunc) (void); > > > Y cuando en Form.C va a compilar las l�neas: > > AddSignal((GtkSignalFunc)Destroy,"delete_event"); > AddSignal(GTK_SIGNAL_FUNC(TForm::Destroy),"destroy"); > > va y me dice que: > > Form.C: In method `TForm::TForm(GtkWindowType)': > Form.C:35: no matches converting function `Destroy' to type `void > (*)()' > Form.h:39: candidates are: void TForm::Destroy() > Form.C:36: assuming & on `TForm::Destroy' > Form.C:36: converting from `void (TForm::*)()' to `void (*)()' > make: *** [Form.o] Error 1 > > He probado a poner el TForm:: delante, y tambi�n el &, pero > nada, al final siempre dice que no puede convertir de void > (TForm::*)() a void (*)() > > �Es que en C++ no se trata igual un puntero a funci�n que un > puntero a un m�todo de una clase? Despistao estoy, desde luego... > > saluti, > Vladimir > > - Seguimos mirando el reloj. Tarifa PLANA sin trucos para todos - �C�mo est� definida Destroy? Creo que en gtk las funciones de retrollamadas deben seguir el siguiente prototipo: func(GtkWidget *widget, gpointer data) Salu2
Technical Details
Message-ID:
<3A02B053.6DC24660@eui.upv.es>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!isdnet!news.rediris.es!news.uv.es!news.upv.es!not-for-mailReferences:
<iipovsknnvs1cgiad4k1i6cebhror9kotf@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII X-Google-Thread: f86c8,9ece04ddd9e65ba1 X-Google-Attributes: gidf86c8,public X-Google-ArrivalTime: 2000-11-03 04:48:02 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!isdnet!news.rediris.es!news.uv.es!news.upv.es!not-for-mail From: migue <migarroi@eui.upv.es> Newsgroups: es.comp.os.linux.programacion Subject: Re: Punteros a funciones en C++ Date: Fri, 03 Nov 2000 13:32:19 +0100 Organization: U.P.V. Lines: 56 Message-ID: <3A02B053.6DC24660@eui.upv.es> References: <iipovsknnvs1cgiad4k1i6cebhror9kotf@4ax.com> NNTP-Posting-Host: tifus06.eui.upv.es Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: polaris.cc.upv.es 973254739 5325 158.42.219.6 (3 Nov 2000 12:32:19 GMT) X-Complaints-To: newsmaster@upv.es NNTP-Posting-Date: 3 Nov 2000 12:32:19 GMT X-Mailer: Mozilla 4.75 [en] (X11; U; Linux 2.2.16-3 i686) X-Accept-Language: en