Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. error C2440

error C2440

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Aint
    wrote on last edited by
    #1

    Hi. I am having this error and I don't know what to do with it.. Please help. error C2440: 'initializing' : cannot convert from 'class CDocument *' to 'class CVector_3DDoc *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast When I double clicked on the error, it points to this code: CCVector_3DDoc* pDoc = GetDocument(); What is wrong with this code? class CVector_3DDoc is a class that I have added with the base class as CDocument. Thanks.

    D V 2 Replies Last reply
    0
    • A Aint

      Hi. I am having this error and I don't know what to do with it.. Please help. error C2440: 'initializing' : cannot convert from 'class CDocument *' to 'class CVector_3DDoc *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast When I double clicked on the error, it points to this code: CCVector_3DDoc* pDoc = GetDocument(); What is wrong with this code? class CVector_3DDoc is a class that I have added with the base class as CDocument. Thanks.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      ReturnRain wrote:

      What is wrong with this code?

      The compiler is telling you exactly what is wrong.

      CCVector_3DDoc* pDoc = (CCVector_3DDoc *) GetDocument();


      "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      A 1 Reply Last reply
      0
      • D David Crow

        ReturnRain wrote:

        What is wrong with this code?

        The compiler is telling you exactly what is wrong.

        CCVector_3DDoc* pDoc = (CCVector_3DDoc *) GetDocument();


        "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        A Offline
        A Offline
        Aint
        wrote on last edited by
        #3

        Hi. Thank for replying. But now I have another error: error C2440: 'type cast' : cannot convert from 'class CDocument *' to 'class CVector_3DDoc' No constructor could take the source type, or constructor overload resolution was ambiguous What does it mean? :confused:

        D 1 Reply Last reply
        0
        • A Aint

          Hi. I am having this error and I don't know what to do with it.. Please help. error C2440: 'initializing' : cannot convert from 'class CDocument *' to 'class CVector_3DDoc *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast When I double clicked on the error, it points to this code: CCVector_3DDoc* pDoc = GetDocument(); What is wrong with this code? class CVector_3DDoc is a class that I have added with the base class as CDocument. Thanks.

          V Offline
          V Offline
          vibindia
          wrote on last edited by
          #4

          Try this ya CCVector_3DDoc* pDoc =reinterpret_cast(GetDocument()); VIBIN "Fool's run away,where angle's fear to tread"

          A 1 Reply Last reply
          0
          • V vibindia

            Try this ya CCVector_3DDoc* pDoc =reinterpret_cast(GetDocument()); VIBIN "Fool's run away,where angle's fear to tread"

            A Offline
            A Offline
            Aint
            wrote on last edited by
            #5

            Thanks!

            M 1 Reply Last reply
            0
            • A Aint

              Hi. Thank for replying. But now I have another error: error C2440: 'type cast' : cannot convert from 'class CDocument *' to 'class CVector_3DDoc' No constructor could take the source type, or constructor overload resolution was ambiguous What does it mean? :confused:

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              ReturnRain wrote:

              ...to 'class CVector_3DDoc'

              The cast operation is wrong. You should be casting one pointer to another.


              "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              1 Reply Last reply
              0
              • A Aint

                Thanks!

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #7

                Please tell me CCVector_3DDoc is derived from CDocument before you go and use reinterpret_cast everywhere to fix everything :)

                "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups