Subject | Re: [IB-Architect] New API: Exceptions |
---|---|
Author | Bill Lancaster |
Post date | 2000-06-02T14:58:35Z |
>Dammit Jim, I'm a programmer not a magician. Did a quick search for error
> catch (const SQLException& exception)
> {
> printf ("Sql error: %s\n", exception.getText());
> }
>
>gets:
>
>Query.cpp(153) : error C2662: 'getText' : cannot convert 'this' pointer
>from 'const class SQLException' to 'class SQLException &'
> Conversion
>loses qualifiers
>
C2662 at MS site and received. Here's the short answer
"STATUS This bug was corrected in Microsoft Visual C++, version 6.0."
FIX: Modifying Const Temporary Object Doesn't Generate Error
----------------------------------------------------------------------------
----
The information in this article applies to:
The C/C++ Compiler (CL.EXE), used with:
Microsoft Visual C++, 32-bit Editions, versions 4.0, 4.1, 4.2, 5.0
----------------------------------------------------------------------------
----
SYMPTOMS
The compiler generates the following error when you invoke a non-const
member function on a const object:
error C2662: 'Set' : cannot convert 'this' pointer from 'const struct A *'
to 'struct A *const '
However, it does not generate this error when you invoke a non-const member
function on a const object that is returned by a function.
RESOLUTION
To work around this problem, make the function return a reference to const.
STATUS
This bug was corrected in Microsoft Visual C++, version 6.0.
:-)