Topic: conversion : operator T(void) vs. operator T(void) const


Author: georgec1@aol.com (Georgec1)
Date: 29 Aug 1994 14:45:02 -0400
Raw View
I have trouble defining both operator T(void) and operator T(void) const
conversion functions in a same class in Borland C++ 4.02.   (T is an
arbitrary type)

Is it legal under ARM conformance to have two implicit conversion
functions that only different in const-ness?  In other words, is the
following code legal?

-- cut here --

// Borland C++ 4.02 has trouble selecting which conversion
// function to apply when such situation arises.

class X {
public:
     operator int (void); // intended for non-constant X object.
     operator int (void) const; // intended for constant X object.
};

-- cut here --

PS. The above code do work under Mac's Symantec C++ 7.02.  See ARM page
272-276 for the conversion discussion.  Although it doesn't say anything
about the const modifier to the conversion function, my feeling is that
the above should work.

Please shed some light on this subject if you know the answer.

Sincerely,

George Chu, infinite, inc.
Georgec1@aol.com