From: Matthew Mastracci Newsgroups: comp.os.msdos.djgpp Subject: Re: Functions in struct's... possible? How? Date: Thu, 21 Aug 1997 22:01:04 -0600 Organization: The University of Calgary Lines: 28 Message-ID: <5tj2vk$m9m@ds2.acs.ucalgary.ca> References: <33FCDA5C DOT 2353659F AT execulink DOT com> NNTP-Posting-Host: mmastrac AT acs2 DOT acs DOT ucalgary DOT ca Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII In-Reply-To: <33FCDA5C.2353659F@execulink.com> To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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?