#C++ Conversion Ops
Joe,
The reason why I was getting a syntax error in trying to declare a conversion
operator in the TCL class CDialogText was due to AppMaker's mapping of .cp
extension files to the Think C compiler, not to Symantec C++. Thus
CDialogText.cp was being compiled in Think C, and so gave a syntax error to
operator long ();
The main point of this reply is that, when one does compile the TCL with
Symantec C++, conversion operators do work! I inserted into the public part of
the class declaration of CDialogText (in the file CDialogText.h) the statement:
operator long ();
I put the actual procedure in CDialogText.cp as
CDialogText :: operator long ()
{
Str255 theString;
long result;
GetTextString( theString); // defined for the class CDialogText
StringToNum( theString, &result); // standard toolbox call
return result;
}
If inputString is an object of the class CDialogText containing a string
suitable for conversion to a long, the statement
long theNumber = inputString;
works as expected.
Bob