Classes[Class]

10 Classes[Class]

10.1 Member Functions[Class.MemberFunctions]

10.1.1 Non-static Member Functions[Class.MemberFunctions.NonStatic]

A non-static member function may be declared const, such a function is called a const member function. The const qualifier of a const member function applies to the this reference, and affects the type of the member function.

10.2 Conversion Functions[Class.MemberFunctions.Conversion]

conversion-function-id:
operator conversion-type-id

A member function of a class named as a conversion-function-id specifies a conversion from the class type to the type specified by the conversion-type-id. Such functions are called conversion functions. No return type is specified. The type of the function is a function taking no parameters returning conversion-type-id.

A conversion function may never be used to convert an object to the same type, to a base class of the type, or to void.

The explicit keyword may be applied to a conversion function declaration (9.2.3). Such functions are said to be explicit conversion functions, which are only considered as a user-defined conversion for direct-initialization or explicit cast expressions.