Re: Calling C++ functions
- From: "William L. Thomson Jr." <support obsidian-studios com>
- To: GTK+ App Devel Mail List <gtk-app-devel-list gnome org>
- Subject: Re: Calling C++ functions
- Date: 26 Jun 2002 14:37:18 -0700
On Wed, 2002-06-26 at 09:47, Wolfgang Draxinger wrote:
William L. Thomson Jr. wrote:
I am having problems calling C++ functions from my GTK buttons.
No, you want to call class members. C++ functions don't differ from C
functions.
Ok?
You know, that a class member function is not the same as a global
function?
Yes, I had not problem with the function when they were not part of a
class. As soon as I add the functions to the class I can not longer call
the function. Most likely due to my lack of knowledge.
There is a standard argument to every class member function:
The this pointer.
class Foo
{
char Bar(int foobar);
};
A class member function pointer type of Foo::Bar(...) is e.g.
char (Foo::*pBar)(int)=&Foo::Bar;
You see, that this has another type than a G_Callback, even if it has
the same parameter list, since the compiler internally makes something like
char Bar Foo(Foo*, int);
from it.
Sorry but this is a little over my head so if I could break it down for
clarity that will help me make sense out of it.
So I need to do something along the lines of
char (Foo::*pBar)(int)=&Foo::Bar;
Inside my class, or as part of my app. And then what would I pass or use
in my button
gtk_signal_connect_object(GTK_OBJECT(new_button),"clicked",GTK_SIGNAL_FUNC(Bar),GTK_OBJECT(window));
to call the Foo classes Bar function?
Please excuse my ignorance. I am trying my best to learn, but I believe
it is important to understand completely even the smallest of concepts.
Also please reserve any insults until the next time you are in front of
a mirror. :)
--
Sincerely,
William L. Thomson Jr.
Support Group
Obsidian-Studios Inc.
439 Amber Way
Petaluma, Ca. 94952
Phone 707.766.9509
Fax 707.766.8989
http://www.obsidian-studios.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]