Rules for Declaring Conversion Functions

The following four rules are used when declaring conversion functions (see Conversion Functions (C++) for syntax):

  • Classes, enumerations, and typedef names cannot be declared in the type-specifier-list. Therefore, the following code generates an error:

    operator struct String{ char string_storage; }();
    

    Instead, declare the String structure prior to the conversion function.

  • Conversion functions take no arguments. Specifying arguments generates an error.

  • Conversion functions have the return type specified by the conversion-type-name; specifying any return type for a conversion function generates an error.

  • Conversion functions can be declared as virtual.

See Also

Reference

Rules for Declaring Conversion Functions