TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: JOHN DUMAS
from: JOE DUNFORD
date: 1998-01-05 18:30:00
subject: C rap

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)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.