www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - Const confusion

↑ ↓ ← "Matthew Wilson" <dmd synesis.com.au> writes:
Walter

The following code:

class X
{
public:
    operator char const * const() const;
    operator char * const();

};


int main(int /* argc */, char ** /*argv*/)
{
    X           x;
    char const  *pc     =   x;

    return 0;
};

gives the error:

    char const  *pc     =   x;
                             ^
h:\dev\test\compiler\dm\xsconst\xsconst.cpp(17) : Error: need explicit cast
to convert
from: X
to  : char const *
--- errorlevel 1

Removing the second const, which is the unnecessary one, from the first line
corrects the confusion. This is a bug with both 8.28 and 8.30.3

Matthew
Sep 22 2002
↑ ↓ "Matthew Wilson" <dmd synesis.com.au> writes:
Walter

The other two I posted at the same time have been resolved, so wondering
whether this one gone under your radar?

Matthew

"Matthew Wilson" <dmd synesis.com.au> wrote in message
news:amlf50$31i8$1 digitaldaemon.com...
 Walter

 The following code:

 class X
 {
 public:
     operator char const * const() const;
     operator char * const();

 };


 int main(int /* argc */, char ** /*argv*/)
 {
     X           x;
     char const  *pc     =   x;

     return 0;
 };

 gives the error:

     char const  *pc     =   x;
                              ^
 h:\dev\test\compiler\dm\xsconst\xsconst.cpp(17) : Error: need explicit

 to convert
 from: X
 to  : char const *
 --- errorlevel 1

 Removing the second const, which is the unnecessary one, from the first

 corrects the confusion. This is a bug with both 8.28 and 8.30.3

 Matthew

Sep 24 2002
↑ ↓ "Walter" <walter digitalmars.com> writes:
"Matthew Wilson" <dmd synesis.com.au> wrote in message
news:amrmea$1rai$1 digitaldaemon.com...
 Walter

 The other two I posted at the same time have been resolved, so wondering
 whether this one gone under your radar?

 Matthew

No, it's still on my todo list.
Sep 25 2002
↑ ↓ → "Matthew Wilson" <dmd synesis.com.au> writes:
:)

"Walter" <walter digitalmars.com> wrote in message
news:amrsgs$22r2$1 digitaldaemon.com...
 "Matthew Wilson" <dmd synesis.com.au> wrote in message
 news:amrmea$1rai$1 digitaldaemon.com...
 Walter

 The other two I posted at the same time have been resolved, so wondering
 whether this one gone under your radar?

 Matthew

No, it's still on my todo list.

Sep 25 2002