Mail Archives: djgpp/1997/08/22/02:05:54
On Thu, 21 Aug 1997, Jeff Weeks wrote:
> I'd like to have a function in a struct that I've created. I realise I
> can't just stick a functions in there, so I used a pointer to a
> function. Here's what my struct looks like:
Curious: are you using straight C or are you using C++? If it's C++, you
can have functions in your structs (even constructors and destructors!).
If you didn't know (forgive me if you did ;), structs in C++ are a
combination of C++ classes and C structs. The basic difference between a
C++ struct and class is that by default, all members of the class are
declared private, while all members of a struct are public by default.
Perhaps you should be looking in the direction of pure virtual
inheritance? You can create the driver interface and just derive all your
driver classes from it. Of course, there is the vfptr overhead (only a
few cycles, I know, but it will add up) which might make a difference in
some situations (especially if a virtual function gets called many times,
like a putpixel function).
Sorry for the OO stuff, I'm just making sure you know about it... ;)
/\/\att /\/\astracci mmastrac AT acs DOT ucalgary DOT ca
GCS/GE d- s+:+ a--- C++++ UA P+ L E-- W+ N++ o K+ w+ O M- V
PS++ PE++ Y+ PGP t+++ 5+++ X++ R++ tv+ b+++ DI++++ I
G++ e h r* z?
- Raw text -