Re: gcc oriented questions



Am 08 Aug 2001 15:03:15 +0200 schrieb David Robin:
> hi,
> 
> here are two different questions:
> - why are callback functions defined as 'static'? Is there an obligation to do so? Does it makes my app faster?

Er, I guess you talking about static class members in C++ ?
A static class member function behaves like an ordinary C function,
e.g. it has no implicit "this"-pointer. Since the GTK+ C-API knows
nothing about C++, you have to declare the callback functions static.

> - can a C++/GTK+ app be as performant as its C/GTK+ counterpart? If C is faster, is there a program that would translate my C++ sources to C (eg. class -> struct etc.)?

That depends on your coding style, but generally: yes.
A class doesn't have any implicit overhead compared to a struct,
if you don't use virtual methods or virtual inheritence. In C++,
a struct is the same as a class except that all members are by
default "public" rather than "private".

If you want to take advantage of C++ features, I'd suggest you
have a look at libsigc++ and GTK--.

http://gtkmm.sourceforge.net/

Regards,
--Daniel





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