Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: Question about const_cast #412153
    AvatarRichard Leute
    Participant
        Up
        0
        Down
        ::

        Ok, thanks! Also it’s a contrived example I got the point. That absolutely makes sense.

        in reply to: Question about const_cast #412147
        AvatarRichard Leute
        Participant
            Up
            0
            Down
            ::

            I am currently working on week 3 and was wondering about const_cast and had the same question in mind as Fabio.
            I can see the point of dealing with legacy software and have in mind a case where legacy software is e.g. returning a const variable X which I want to modify. So I would use a const_cast to get rid of the constness. However, I can not see the point of casting away const from X if any modification of X would lead to undefined behaviour. So can you give an example where casting away const makes sense?
            Thanks in advance. I hope I have not missed an important point in your conversation.

          Viewing 2 posts - 1 through 2 (of 2 total)