JD>I would like to see a very small example, without error checking or any
JD>other extra stuff, of "wrapping a c module to work in C++".
JD>I have seen it mentioned several times but never ex-plain-ed. :(
To me, "wrapping" is akin to writing a wrapper. This simply means that
you write a C++ class that encapsulates C functions. For example:
C functions:
One (char* data);
Two (char* data,int number);
C++ wrapper:
class T_THINGY {
char* some_data;
int some_number;
public:
One (char* data);
Two (char* data, int number);
};
This is usually done so that "ports" of C to C++ go smoother. One of the
major design paradigms in C++ is to create classes where the interface
doesn't change. By "wrapping" C functions it is possible to ensure that
this ideal is preserved.
For instance if someone changes the C function (above) from One (char*
data) to One (char* data,float percent) then the class/wrapper writer
can (hopefully) alter the internal workings of T_THINGY::One so that the
user of the class can still use One(char* data). Of course, in
the example I've given that would be pretty tough. ;)
Hope that helps.
___
þ SLMR 2.1a þ All hope abandon, ye who enter messages here.
--- Maximus 3.01
---------------
* Origin: C+Net BBS. Programming & Networking. (1:342/601)
|