Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!cs.utexas.edu!rutgers!elbereth.rutgers.edu!rgonzal From: rgonzal@elbereth.rutgers.edu (Ralph Gonzalez) Newsgroups: comp.sys.mac.programmer Subject: Re: Think C 4.0 evolving to C++ Message-ID: Date: 26 Feb 91 13:48:19 GMT References: <0.27C5B492@mmug.edgar.mn.org> Organization: Rutgers Univ., New Brunswick, N.J. Lines: 56 As mentioned in the Think C manuals, you can get Think C/C++ compatibility as far as "virtual" is concerned by using "virtual" in all method declarations, and saying: # ifdef THINK_C # define virtual # endif A few other requirements: C++ doesn't support Think C's method of avoiding multiple inclusion of header files. So you must use the usual C++ approach for all headers: # ifndef filename_h # define filename_h (body of header file) # endif "direct" and "indirect" specifiers are not used in C++, so you should use something like this in your root class: # ifdef THINK_C struct Generic_Class:indirect # else struct Generic_Class # endif { virtual boolean init(void); . . . }; Since "new" and "delete" are implemented as functions in Think C and operators in C++, you need this in any file using them (or in a common header): # ifdef THINK_C # include # endif Since it is not supported in C++, you can't use Think C's "inherited" keyword. You should instead use the name of the base class explicitly. I've had good luck in Think C/C++ portability by following the above rules. There are also a couple of bugs in Think C which you have to work around, but these don't come up too often... -Ralph rgonzal@chowder.rutgers.edu